Find answers from the community

Home
Members
mingsheng
m
mingsheng
Offline, last seen 3 months ago
Joined September 25, 2024
Hello,
I am trying out the code snippet obtained from claude https://github.com/anthropics/anthropic-cookbook/blob/main/third_party/LlamaIndex/Basic_RAG_With_LlamaIndex.ipynb

Instead of using claude, I am trying to use bedrock services claude-sonnet model and cohere-english-v3. But the problem is that it will fail whenever I am try to create vectorstore index with the following error:
ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #/texts/1: expected maxLength: 2048, actual: 2166#/texts/2: expected maxLength: 2048, actual: 2312#/texts/3: expected maxLength: 2048, actual: 2315#/texts/4: expected maxLength: 2048, actual: 2151#/texts/6: expected maxLength: 2048, actual: 2072#/texts/7: expected maxLength: 2048, actual: 2164#/texts/8: expected maxLength: 2048, actual: 2091#/texts/9: expected maxLength: 2048, actual: 2201, please reformat your input and try again.

My code:
from llama_index.llms.bedrock import Bedrock
from llama_index.embeddings.bedrock import BedrockEmbedding
from llama_index.core import Settings
from llama_index.core import (
VectorStoreIndex,
SimpleDirectoryReader,
)
llm = Bedrock(model="anthropic.claude-3-sonnet-20240229-v1:0", region_name='us-west-2')
embed_model = BedrockEmbedding(service_name="bedrock-runtime", model="cohere.embed-english-v3", region_name='us-west-2')

Settings.llm = llm
Settings.embed_model = embed_model
Settings.chunk_size = 512

documents = SimpleDirectoryReader("./data").load_data()
index = VectorStoreIndex.from_documents(documents,)
query_engine = index.as_query_engine(similarity_top_k=3)
response = query_engine.query("What did author do growing up?")
Am I doing something wrong ?
11 comments
m
L
W
Hello everyone, I am trying to load api response into document and into vector store later. If for example my api response with "absctract" and "key points" , I know that i can set up document with two different fields but what about index and vector store retrievers, is there any way that i can use two different retrievers on the two attributes?
3 comments
T
m