Skip to content

Commit 65a890e

Browse files
authored
Update the version to 0.1.31 (#429)
Signed-off-by: SimFG <bang.fu@zilliz.com>
1 parent 3ed5352 commit 65a890e

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

docs/release_note.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,81 @@ To read the following content, you need to understand the basic use of GPTCache,
55
- [Readme doc](https://github.com/zilliztech/GPTCache)
66
- [Usage doc](https://github.com/zilliztech/GPTCache/blob/main/docs/usage.md)
77

8+
## v0.1.31 (2023.6.14)
9+
10+
1. To improve the precision of cache hits, two similarity evaluation methods were added
11+
12+
a. SBERT CrossEncoder Evaluation
13+
14+
```python
15+
from gptcache.similarity_evaluation import SbertCrossencoderEvaluation
16+
evaluation = SbertCrossencoderEvaluation()
17+
score = evaluation.evaluation(
18+
{
19+
'question': 'What is the color of sky?'
20+
},
21+
{
22+
'question': 'hello'
23+
}
24+
)
25+
```
26+
27+
b. Cohere rerank api (**Free accounts can make up to 100 calls per minute.**)
28+
29+
```python
30+
from gptcache.similarity_evaluation import CohereRerankEvaluation
31+
32+
evaluation = CohereRerankEvaluation()
33+
score = evaluation.evaluation(
34+
{
35+
'question': 'What is the color of sky?'
36+
},
37+
{
38+
'answer': 'the color of sky is blue'
39+
}
40+
)
41+
```
42+
43+
c. Multi-round dialog similarity weight matching
44+
45+
```python
46+
from gptcache.similarity_evaluation import SequenceMatchEvaluation
47+
48+
weights = [0.5, 0.3, 0.2]
49+
evaluation = SequenceMatchEvaluation(weights, 'onnx')
50+
51+
query = {
52+
'question': 'USER: "foo2" USER: "foo4"',
53+
}
54+
55+
cache = {
56+
'question': 'USER: "foo6" USER: "foo8"',
57+
}
58+
59+
score = evaluation.evaluation(query, cache)
60+
```
61+
62+
d. Time Evaluation. For the cached answer, first check the time dimension, such as only using the generated cache for the past day
63+
64+
```python
65+
from gptcache.similarity_evaluation import TimeEvaluation
66+
67+
evaluation = TimeEvaluation(evaluation="distance", time_range=86400)
68+
69+
similarity = eval.evaluation(
70+
{},
71+
{
72+
"search_result": (3.5, None),
73+
"cache_data": CacheData("a", "b", create_on=datetime.datetime.now()),
74+
},
75+
)
76+
```
77+
78+
2. Fix some bugs
79+
80+
a. OpenAI exceptions type #416
81+
b. LangChainChat does work with _agenerate function #400
82+
883
## v0.1.30 (2023.6.7)
984

1085
1. Support to use the cohere rerank api to evaluate the similarity

gptcache/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""gptcache version"""
2-
__version__ = "0.1.30"
2+
__version__ = "0.1.31"
33

44
from gptcache.config import Config
55
from gptcache.core import Cache

gptcache/similarity_evaluation/cohere_rerank.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CohereRerank(SimilarityEvaluation):
2323
2424
from gptcache.similarity_evaluation import CohereRerankEvaluation
2525
26-
evaluation = CohereRerank()
26+
evaluation = CohereRerankEvaluation()
2727
score = evaluation.evaluation(
2828
{
2929
'question': 'What is the color of sky?'

gptcache/similarity_evaluation/time.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ class TimeEvaluation(SimilarityEvaluation):
1010
for example, only use the cache within 1 day from the current time,
1111
and filter out the previous cache.
1212
13+
:param evaluation: Similarity evaluation, like distance/onnx.
14+
:param evaluation_config: Similarity evaluation config.
15+
:param time_range: Time range, time unit: s
16+
17+
Example:
18+
.. code-block:: python
19+
20+
import datetime
21+
22+
from gptcache.manager.scalar_data.base import CacheData
23+
from gptcache.similarity_evaluation import TimeEvaluation
24+
25+
evaluation = TimeEvaluation(evaluation="distance", time_range=86400)
26+
27+
similarity = eval.evaluation(
28+
{},
29+
{
30+
"search_result": (3.5, None),
31+
"cache_data": CacheData("a", "b", create_on=datetime.datetime.now()),
32+
},
33+
)
34+
# 0.5
35+
1336
"""
1437

1538
def __init__(self, evaluation: str, evaluation_config=None, time_range: float = 86400.0):

0 commit comments

Comments
 (0)