Skip to content
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

[WIP] Semantic search endpoint #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Click on each to see the parameters!

* [classify](docs/classify.md) : `POST /classify/`

#### Semantic search (multilingual) 🔍

* [semsearch](docs/semsearch.md) : `POST /semsearch/`

## Using the API 🔥

* Python:
Expand Down
62 changes: 62 additions & 0 deletions docs/semsearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Semantic Search

Given a query sentence or paragraph, and a set of key sentences, compute probabilities of the query being similar to any of the key sentences
http://api.vicgalle.net:5000/docs#/default/generate_semsearch_post

**URL** : `/semsearch/`

**Method** : `POST`

**Data parameters**

```json
{
"query": "[string, the text to be searched in the other set]",
"keys": "[list of string, the key sentences separated by comma and surrounded with " "]",
}
```

**Data example**

```json
{
"query": "That is a happy person",
"keys": ""That is a happy dog","That is a very happy person","Today is a sunny day"",
}
```

## Success Response

**Code** : `200 OK`

**Content example**

`scores` for the key sentences (from 0 to 1), in the same order returned by keys.

```json
{
"query": "That is a happy person",
"keys": [
"That is a happy dog",
"That is a very happy person",
"Today is a sunny day"
],
"scores": [
0.6623498797416687,
0.9382339715957642,
0.2296333611011505
]
}
```

## Python Example

```python
import requests
payload = {
"query" : "That is a happy person",
"keys" : ""That is a happy dog","That is a very happy person","Today is a sunny day""}
response = requests.post("http://api.vicgalle.net:5000/semsearch", params=payload).json()
print(response)

```