oshizo's picture
Update README.md
4caac69
---
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))