English
Portuguese
cnmoro commited on
Commit
aa7f02b
·
verified ·
1 Parent(s): 28cc4a7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -3
README.md CHANGED
@@ -1,3 +1,80 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - sentence-transformers/msmarco-msmarco-distilbert-base-tas-b
5
+ language:
6
+ - en
7
+ - pt
8
+ ---
9
+
10
+ A really tiny sentence reranker (models use only 60mb) that runs almost instantly on cpu.
11
+
12
+ Trained using a mix of embeddings from wordllama and hashingvectorizer, on a dataset based on msmarco.
13
+
14
+ * pip install nanoranker
15
+
16
+ ```python
17
+ from nanoranker import rank
18
+
19
+ query = "Who directed 'Inception'?"
20
+ documents = [
21
+ "'Inception' is a 2010 science fiction film directed by Christopher Nolan. It explores the concept of dream invasion and manipulation.",
22
+ "Steven Spielberg is one of the most well-known directors of all time, famous for films like 'E.T.', 'Jaws', and 'Jurassic Park'.",
23
+ "'Titanic', directed by James Cameron, was released in 1997 and became one of the highest-grossing films of all time.",
24
+ "Christopher Nolan is a British-American filmmaker known for his cerebral and nonlinear storytelling in movies like 'Memento', 'The Dark Knight', and 'Inception'.",
25
+ "Martin Scorsese directed the crime drama 'Goodfellas', which is considered a masterpiece in the gangster film genre."
26
+ ]
27
+
28
+ rank(query, documents)
29
+ # Output:
30
+ # [("'Inception' is a 2010 science fiction film directed by Christopher Nolan. It explores the concept of dream invasion and manipulation.",
31
+ # 0.30231907351694276),
32
+ # ("'Titanic', directed by James Cameron, was released in 1997 and became one of the highest-grossing films of all time.",
33
+ # 0.19274971230156498),
34
+ # ("Steven Spielberg is one of the most well-known directors of all time, famous for films like 'E.T.', 'Jaws', and 'Jurassic Park'.",
35
+ # 0.19266481513294043),
36
+ # ("Martin Scorsese directed the crime drama 'Goodfellas', which is considered a masterpiece in the gangster film genre.",
37
+ # 0.1603303513065687),
38
+ # ("Christopher Nolan is a British-American filmmaker known for his cerebral and nonlinear storytelling in movies like 'Memento', 'The Dark Knight', and 'Inception'.",
39
+ # 0.15193604774198313)]
40
+
41
+ query = "What is the speed of light?"
42
+ documents = [
43
+ "The speed of light in a vacuum is approximately 299,792 kilometers per second (km/s), or about 186,282 miles per second.",
44
+ "Isaac Newton's laws of motion and gravity laid the groundwork for classical mechanics.",
45
+ "The theory of relativity, proposed by Albert Einstein, has revolutionized our understanding of space, time, and gravity.",
46
+ "The Earth orbits the Sun at an average distance of about 93 million miles, taking roughly 365.25 days to complete one revolution.",
47
+ "Light can be described as both a wave and a particle, a concept known as wave-particle duality."
48
+ ]
49
+ # Output:
50
+ # [("Isaac Newton's laws of motion and gravity laid the groundwork for classical mechanics.",
51
+ # 0.26837394568994555),
52
+ # ('The speed of light in a vacuum is approximately 299,792 kilometers per second (km/s), or about 186,282 miles per second.',
53
+ # 0.22389275760593016),
54
+ # ('Light can be described as both a wave and a particle, a concept known as wave-particle duality.',
55
+ # 0.2190827494212158),
56
+ # ('The Earth orbits the Sun at an average distance of about 93 million miles, taking roughly 365.25 days to complete one revolution.',
57
+ # 0.15447457049559693),
58
+ # ('The theory of relativity, proposed by Albert Einstein, has revolutionized our understanding of space, time, and gravity.',
59
+ # 0.13417597678731155)]
60
+
61
+ query = "Who wrote 'Pride and Prejudice'?"
62
+ documents = [
63
+ "Pride and Prejudice is a novel written by Jane Austen, first published in 1813. It is a classic of English literature.",
64
+ "Charlotte Brontë, known for her novel Jane Eyre, was a 19th-century English novelist.",
65
+ "William Shakespeare is often considered the greatest playwright in the English language, famous for works such as Hamlet, Romeo and Juliet, and Macbeth.",
66
+ "Pride and Prejudice explores themes of love, social status, and individual growth, set in the British Regency era.",
67
+ "Jane Austen, an English novelist, is renowned for her works that critique the British landed gentry of the 18th century."
68
+ ]
69
+ # Output:
70
+ # [('Pride and Prejudice explores themes of love, social status, and individual growth, set in the British Regency era.',
71
+ # 0.29640036907108874),
72
+ # ('William Shakespeare is often considered the greatest playwright in the English language, famous for works such as Hamlet, Romeo and Juliet, and Macbeth.',
73
+ # 0.22162575844903826),
74
+ # ('Jane Austen, an English novelist, is renowned for her works that critique the British landed gentry of the 18th century.',
75
+ # 0.21914652110923447),
76
+ # ('Pride and Prejudice is a novel written by Jane Austen, first published in 1813. It is a classic of English literature.',
77
+ # 0.143248682405217),
78
+ # ('Charlotte Brontë, known for her novel Jane Eyre, was a 19th-century English novelist.',
79
+ # 0.11957866896542155)]
80
+ ```