-
Notifications
You must be signed in to change notification settings - Fork 106
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
Error using custom imported Llama3.1 model on Bedrock #228
Comments
@mgaionWalit |
Thanks for the reply. There is a temporary workaround? |
@mgaionWalit |
@mgaionWalit |
Hi @3coins thanks for you support. I've updated langchain-aws to the latest available version (0.2.4) and tried to init the custom model with ChatBedrockConverse :
but I still get an error when trying to start a chat with stream that says: Am I doing something wrong? Do you have some suggestions on how to make it work? |
Per conversation, we actually looked at Converse support for custom import models. I was able to work on the issue; Since it was created, Bedrock has added Converse support for custom import models and it is expected the user adds a correct chat template. For the model mentioned in the issue Meta-Llama-3.1-8B-Instruct, the custom import supports Converse. The list of supported models and how to set up the template is documented in the AWS Bedrock User Guide, Converse API code samples for custom model import. Here is the list of steps I did to make it work:
from langchain_aws import ChatBedrockConverse
from langchain_aws import ChatBedrock
def main():
# Initializing Bedrock chat converse for imported models
llm = ChatBedrockConverse(
model_id='arn:aws:bedrock:us-east-1:xxxxxxx:imported-model/xxxxxxxx', # here I set the arn of the imported model
region_name="us-east-1",
provider='meta',
temperature=0.15,
max_tokens=100
)
# Invoke the llm
response = llm.invoke("What is Amazon Web Services?)
print(response.content)
if __name__ == '__main__':
main() and it will yield an output:
|
We are using a fine-tuned version of Llama 3.1-instruct, uploaded to Bedrock. Since we are using an ARN model ID (which does not contain any information about the specific Foundation Model used), we encountered an issue.
In the code
chat_models/bedrock.py
at line 349, there is an if statement evaluating the model string to choose between Llama2 and Llama3 for prompt conversion.In our case, we need to use
convert_messages_to_prompt_llama3
, but the logic falls into the else statement, which usesconvert_messages_to_prompt_llama
.Is there any solution to ensure the correct conversion function is used?
Thank you!
The text was updated successfully, but these errors were encountered: