improve embeddings API results

This commit is contained in:
josc146 2023-07-25 20:30:43 +08:00
parent 77868c798b
commit 1df345b5eb
4 changed files with 11 additions and 2 deletions

View File

@ -91,6 +91,9 @@ body.json:
## Embeddings API Example ## Embeddings API Example
Note: v1.4.0 has improved the quality of embeddings API. The generated results are not compatible
with previous versions. If you are using embeddings API to generate knowledge bases or similar, please regenerate.
If you are using langchain, just use `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")` If you are using langchain, just use `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`
```python ```python

View File

@ -91,7 +91,11 @@ body.json:
## 埋め込み API の例 ## 埋め込み API の例
LangChain を使用している場合は、`OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`を使用してください Note: v1.4.0 has improved the quality of embeddings API. The generated results are not compatible
with previous versions. If you are using embeddings API to generate knowledge bases or similar, please regenerate.
LangChain を使用している場合は、`OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`
を使用してください
```python ```python
import numpy as np import numpy as np

View File

@ -89,6 +89,8 @@ body.json:
## Embeddings API 示例 ## Embeddings API 示例
注意: 1.4.0 版本对embeddings API质量进行了改善生成结果与之前的版本不兼容如果你正在使用此API生成知识库等请重新生成
如果你在用langchain, 直接使用 `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")` 如果你在用langchain, 直接使用 `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`
```python ```python

View File

@ -69,7 +69,7 @@ class AbstractRWKV(ABC):
self.model_state = None self.model_state = None
self.model_tokens = [] self.model_tokens = []
_, token_len = self.run_rnn(self.fix_tokens(self.pipeline.encode(input))) _, token_len = self.run_rnn(self.fix_tokens(self.pipeline.encode(input)))
embedding = self.model_state[-5].tolist() embedding = self.model_state[-11].tolist()
embedding = (embedding / np.linalg.norm(embedding)).tolist() embedding = (embedding / np.linalg.norm(embedding)).tolist()
return embedding, token_len return embedding, token_len