openai/openai-python

Public

mirrored fromhttps://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.18.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

examples/semanticsearch/README.md

30lines · modecode

1# semanticsearch
2
3A client-side implementation of our semantic search endpoint (https://beta.openai.com/docs/api-reference/search).
4
5Our endpoint has a special fast implementation of this logic which
6makes it very fast for calls involving many documents, so we recommend
7using our implementation rather than this one for latency-sensitive
8workloads.
9
10We encourage you to try different variants of this client-side logic
11-- we don't think our setup is likely optimal at all!
12
13## Sample usage
14
15The following usage will run a client-side semantic search. This
16formats each document into a prompt asking the API for the document's
17relevance, and then post-processes the logprobs to derive relevance
18scores:
19
20```
21$ ./semanticsearch.py -q 'positive emotion' -d happy -d sad
22[client-side semantic search] {'object': 'list', 'data': [{'object': 'search_result', 'document': 0, 'score': 204.448}, {'object': 'search_result', 'document': 1, 'score': 108.208}], 'model': 'ada:2020-05-03'}
23```
24
25We run the exact same logic server-side:
26
27```
28$ ./semanticsearch.py -q 'positive emotion' -d happy -d sad -s
29[server-side semantic search] {'object': 'list', 'data': [{'object': 'search_result', 'document': 0, 'score': 204.448}, {'object': 'search_result', 'document': 1, 'score': 108.208}], 'model': 'ada:2020-05-03'}
30```
31