Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Amazon Titan #2165

Merged
merged 3 commits into from
Feb 17, 2024
Merged

Add Amazon Titan #2165

merged 3 commits into from
Feb 17, 2024

Conversation

yifanmai
Copy link
Collaborator

@yifanmai yifanmai commented Dec 19, 2023

Also adds BedrockClient which can be specialized to run other models on Amazon Bedrock.


if assumed_role:
sts = session.client("sts")
response = sts.assume_role(RoleArn=str(assumed_role), RoleSessionName="langchain-llm-1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called langchain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notebook that this code was sourced from (see the code comment for the URL) also had some LangChain tutorials, so I assume they just called it langchain because of that.

From the assume_role docs, it looks like this is just an arbitrary user-defined tag, so I'll set it to "crfm-helm" instead.

@JosselinSomervilleRoberts
Copy link
Contributor

@yifanmai , do we want to merge this?

@yifanmai
Copy link
Collaborator Author

yifanmai commented Feb 7, 2024

@JosselinSomervilleRoberts this is ready for review, could you take a look?

# - https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-titan-models-express-lite-bedrock/
- name: amazon/titan-text-lite-v1
display_name: Amazon Titan Text Lite
description: Amazon Titan Text Lite is a lightweight, efficient model perfect for fine-tuning English-language tasks like summarization and copywriting. It caters to customers seeking a smaller, cost-effective, and highly customizable model. It supports various formats, including text generation, code generation, rich text formatting, and orchestration (agents). Key model attributes encompass fine-tuning, text generation, code generation, and rich text formatting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These descriptions seem a bit subjectives. I thought we were making descriptions about scientific content not so much use cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are copy and pasted from the linked blog post. I wasn't able to find a model card or paper with a more suitable description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have the optional args provided here ? Like bedrock_model_id ?

raw_request = self.convert_request_to_raw_request(request)

# modelId isn't part of raw_request, so it must be explicitly passed into the input to
raw_request_for_cache: Dict = {"modelId": model_id, **deepcopy(raw_request)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't use camel case for cache keys

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using camel case will avoid having to do extra post-processing before sending to the server. Generally, we want the cache key to be as close to the actual parameters that we sent to the API as possible. See AI21Client for another example of a camel case request.

Comment on lines 89 to 109
"inputText": request.prompt,
"textGenerationConfig": {
"maxTokenCount": request.max_tokens,
# Sending a non-empty stopSequences results in an error:
# https://github.com/boto/boto3/issues/3993
"stopSequences": request.stop_sequences or [],
"temperature": request.temperature,
"topP": request.top_p,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

@yifanmai yifanmai force-pushed the yifanmai/fix-add-titan branch from 1cdb05c to 63b5dce Compare February 17, 2024 00:43
@yifanmai yifanmai merged commit aa3e20b into main Feb 17, 2024
6 checks passed
@yifanmai yifanmai deleted the yifanmai/fix-add-titan branch February 17, 2024 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants