nreimers commited on
Commit
caf814d
1 Parent(s): 7328914

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -0
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - ko
4
+
5
+ multilinguality:
6
+ - multilingual
7
+
8
+ size_categories: []
9
+ source_datasets: []
10
+ tags: []
11
+
12
+ task_categories:
13
+ - text-retrieval
14
+
15
+ license:
16
+ - apache-2.0
17
+
18
+ task_ids:
19
+ - document-retrieval
20
+ ---
21
+
22
+ # Wikipedia (ko) embedded with cohere.ai `multilingual-22-12` encoder
23
+
24
+ We encoded [Wikipedia (ko)](https://ko.wikipedia.org) using the [cohere.ai](https://txt.cohere.ai/multilingual/) `multilingual-22-12` embedding model.
25
+
26
+ To get an overview how this dataset was created and pre-processed, have a look at [Cohere/wikipedia-22-12](https://huggingface.co/datasets/Cohere/wikipedia-22-12).
27
+
28
+
29
+ ## Embeddings
30
+ We compute for `title+" "+text` the embeddings using our `multilingual-22-12` embedding model, a state-of-the-art model that works for semantic search in 100 languages. If you want to learn more about this model, have a look at [cohere.ai multilingual embedding model](https://txt.cohere.ai/multilingual/).
31
+
32
+ ## Further languages
33
+ We provide embeddings of Wikipedia in many different languages:
34
+ [ar](https://huggingface.co/datasets/Cohere/wikipedia-22-12-ar-embeddings), [de](https://huggingface.co/datasets/Cohere/wikipedia-22-12-de-embeddings), [en](https://huggingface.co/datasets/Cohere/wikipedia-22-12-en-embeddings), [es](https://huggingface.co/datasets/Cohere/wikipedia-22-12-es-embeddings), [fr](https://huggingface.co/datasets/Cohere/wikipedia-22-12-fr-embeddings), [hi](https://huggingface.co/datasets/Cohere/wikipedia-22-12-hi-embeddings), [it](https://huggingface.co/datasets/Cohere/wikipedia-22-12-it-embeddings), [ja](https://huggingface.co/datasets/Cohere/wikipedia-22-12-ja-embeddings), [ko](https://huggingface.co/datasets/Cohere/wikipedia-22-12-ko-embeddings), [simple english](https://huggingface.co/datasets/Cohere/wikipedia-22-12-simple-embeddings), [zh](https://huggingface.co/datasets/Cohere/wikipedia-22-12-zh-embeddings),
35
+
36
+ You can find the Wikipedia datasets without embeddings at [Cohere/wikipedia-22-12](https://huggingface.co/datasets/Cohere/wikipedia-22-12).
37
+
38
+
39
+ ## Loading the dataset
40
+ You can either load the dataset like this:
41
+ ```python
42
+ from datasets import load_dataset
43
+ docs = load_dataset(f"Cohere/wikipedia-22-12-ko-embeddings", split="train")
44
+ ```
45
+
46
+ Or you can also stream it without downloading it before:
47
+ ```python
48
+ from datasets import load_dataset
49
+ docs = load_dataset(f"Cohere/wikipedia-22-12-ko-embeddings", split="train", streaming=True)
50
+
51
+ for doc in docs:
52
+ docid = doc['id']
53
+ title = doc['title']
54
+ text = doc['text']
55
+ emb = doc['emb']
56
+ ```
57
+
58
+ ## Search
59
+ A full search example:
60
+ ```python
61
+ #Run: pip install cohere datasets
62
+ from datasets import load_dataset
63
+ import torch
64
+ import cohere
65
+
66
+ co = cohere.Client(f"<<COHERE_API_KEY>>") # Add your cohere API key from www.cohere.com
67
+
68
+ #Load at max 1000 documents + embeddings
69
+ max_docs = 1000
70
+ docs_stream = load_dataset(f"Cohere/wikipedia-22-12-ko-embeddings", split="train", streaming=True)
71
+
72
+ docs = []
73
+ doc_embeddings = []
74
+
75
+ for doc in docs_stream:
76
+ docs.append(doc)
77
+ doc_embeddings.append(doc['emb'])
78
+ if len(docs) >= max_docs:
79
+ break
80
+
81
+ doc_embeddings = torch.tensor(doc_embeddings)
82
+
83
+ query = 'Who founded Youtube'
84
+ response = co.embed(texts=[query], model='multilingual-22-12')
85
+ query_embedding = response.embeddings
86
+ query_embedding = torch.tensor(query_embedding)
87
+
88
+ # Compute dot score between query embedding and document embeddings
89
+ dot_scores = torch.mm(query_embedding, doc_embeddings.transpose(0, 1))
90
+ top_k = torch.topk(dot_scores, k=3)
91
+
92
+ # Print results
93
+ print("Query:", query)
94
+ for doc_id in top_k.indices[0].tolist():
95
+ print(docs[doc_id]['title'])
96
+ print(docs[doc_id]['text'], "\n")
97
+ ```
98
+
99
+
100
+ ## Performance
101
+ You can find performance on the MIRACL dataset (a semantic search evaluation dataset) here: [miracl-en-queries-22-12#performance](https://huggingface.co/datasets/Cohere/miracl-en-queries-22-12#performance)