-
Notifications
You must be signed in to change notification settings - Fork 41
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
example error #35
Comments
Hi, @abdoelsayed2016. Did you try to start from this example instead (using Hugging Face embeddings)? These example input embeddings from Vicuna perform really poorly (same for output embeddings), I don't recommend using either. If you really want to use these embeddings, you need to implement a custom embeddings class for langchain. Try modifying this class that I wrote in the Medium article: class VicunaEmbeddings(BaseModel, Embeddings):
def _call(self, prompt: str) -> str:
p = prompt.strip()
print("Sending prompt ", p)
response = requests.post(
"http://127.0.0.1:8000/embedding",
json={
"prompt": p,
},
)
response.raise_for_status()
return response.json()["response"]
def embed_documents(
self, texts: List[str], chunk_size: Optional[int] = 0
) -> List[List[float]]:
"""Call out to Vicuna's server embedding endpoint for embedding search docs.
Args:
texts: The list of texts to embed.
chunk_size: The chunk size of embeddings. If None, will use the chunk size
specified by the class.
Returns:
List of embeddings, one for each text.
"""
results = []
for text in texts:
response = self.embed_query(text)
results.append(response)
return results
def embed_query(self, text) -> List[float]:
"""Call out to Vicuna's server embedding endpoint for embedding query text.
Args:
text: The text to embed.
Returns:
Embedding for the text.
"""
embedding = self._call(text)
return embedding |
I get an error while trying to use llama for embedding in your example.
embedding_function=self._embedding_function.embed_documents
AttributeError: 'function' object has no attribute 'embed_documents'
The text was updated successfully, but these errors were encountered: