File size: 1,050 Bytes
3948207 a480cad 3948207 a480cad 5ecb0f1 4caac69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
---
license: cc-by-sa-4.0
language:
- ja
---
The following data set was vectorized with the [intfloat/multilingual-e5-base](https://huggingface.co./intfloat/multilingual-e5-base) model and an index file created by faiss.
[oshizo/japanese-wikipedia-paragraphs](https://huggingface.co./datasets/oshizo/japanese-wikipedia-paragraphs)
## Usage
First, download index_me5-base_IVF2048_PQ192.faiss from this repository.
```python
import faiss
import datasets
from sentence_transformers import SentenceTransformer
ds = datasets.load_dataset("oshizo/japanese-wikipedia-paragraphs", split="train")
index = faiss.read_index("./index_me5-base_IVF2048_PQ192.faiss")
model = SentenceTransformer("intfloat/multilingual-e5-base")
question = "日本で二番目に高い山は?"
emb = model.encode(["query: " + question])
scores, indexes = index.search(emb, 10)
scores = scores[0]
indexes = indexes[0]
results = []
for idx, score in zip(indexes, scores):
idx = int(idx)
passage = ds[idx]
passage["score"] = score
results.append((passage))
|