@@ -15,14 +15,36 @@ class FakeEmbeddings(Embeddings, BaseModel):
15
15
16
16
Do not use this outside of testing, as it is not a real embedding model.
17
17
18
- Example:
19
-
18
+ Instantiate:
20
19
.. code-block:: python
21
20
22
21
from langchain_core.embeddings import FakeEmbeddings
22
+ embed = FakeEmbeddings(size=100)
23
+
24
+ Embed single text:
25
+ .. code-block:: python
26
+
27
+ input_text = "The meaning of life is 42"
28
+ vector = embed.embed_query(input_text)
29
+ print(vector[:3])
30
+
31
+ .. code-block:: python
32
+
33
+ [-0.700234640213188, -0.581266257710429, -1.1328482266445354]
34
+
35
+ Embed multiple texts:
36
+ .. code-block:: python
37
+
38
+ input_texts = ["Document 1...", "Document 2..."]
39
+ vectors = embed.embed_documents(input_texts)
40
+ print(len(vectors))
41
+ # The first 3 coordinates for the first vector
42
+ print(vectors[0][:3])
43
+
44
+ .. code-block:: python
23
45
24
- fake_embeddings = FakeEmbeddings(size=100)
25
- fake_embeddings.embed_documents(["hello world", "foo bar"])
46
+ 2
47
+ [-0.5670477847544458, -0.31403828652395727, -0.5840547508955257]
26
48
"""
27
49
28
50
size : int
@@ -48,14 +70,36 @@ class DeterministicFakeEmbedding(Embeddings, BaseModel):
48
70
49
71
Do not use this outside of testing, as it is not a real embedding model.
50
72
51
- Example:
52
-
73
+ Instantiate:
53
74
.. code-block:: python
54
75
55
76
from langchain_core.embeddings import DeterministicFakeEmbedding
77
+ embed = DeterministicFakeEmbedding(size=100)
78
+
79
+ Embed single text:
80
+ .. code-block:: python
81
+
82
+ input_text = "The meaning of life is 42"
83
+ vector = embed.embed_query(input_text)
84
+ print(vector[:3])
85
+
86
+ .. code-block:: python
87
+
88
+ [-0.700234640213188, -0.581266257710429, -1.1328482266445354]
89
+
90
+ Embed multiple texts:
91
+ .. code-block:: python
92
+
93
+ input_texts = ["Document 1...", "Document 2..."]
94
+ vectors = embed.embed_documents(input_texts)
95
+ print(len(vectors))
96
+ # The first 3 coordinates for the first vector
97
+ print(vectors[0][:3])
98
+
99
+ .. code-block:: python
56
100
57
- fake_embeddings = DeterministicFakeEmbedding(size=100)
58
- fake_embeddings.embed_documents(["hello world", "foo bar"])
101
+ 2
102
+ [-0.5670477847544458, -0.31403828652395727, -0.5840547508955257]
59
103
"""
60
104
61
105
size : int
0 commit comments