embed-anything-gpu 0.4.4__cp38-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- embed_anything/__init__.py +127 -0
- embed_anything/_embed_anything.cp38-win_amd64.pyd +0 -0
- embed_anything/_embed_anything.pyi +353 -0
- embed_anything/libiomp5md.dll +0 -0
- embed_anything/py.typed +0 -0
- embed_anything/vectordb.py +29 -0
- embed_anything_gpu-0.4.4.dist-info/METADATA +322 -0
- embed_anything_gpu-0.4.4.dist-info/RECORD +10 -0
- embed_anything_gpu-0.4.4.dist-info/WHEEL +4 -0
- embed_anything_gpu-0.4.4.dist-info/license_files/LICENSE +201 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""This module provides functions and classes for embedding queries, files, and
|
|
2
|
+
directories using different embedding models.
|
|
3
|
+
|
|
4
|
+
The module includes the following functions:
|
|
5
|
+
|
|
6
|
+
- `embed_query`: Embeds the given query and returns an EmbedData object.
|
|
7
|
+
- `embed_file`: Embeds the file at the given path and returns a list of EmbedData objects.
|
|
8
|
+
- `embed_directory`: Embeds all the files in the given directory and returns a list of EmbedData objects.
|
|
9
|
+
|
|
10
|
+
The module also includes the `EmbedData` class, which represents the data of an embedded file.
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
------
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import embed_anything
|
|
17
|
+
from embed_anything import EmbedData
|
|
18
|
+
|
|
19
|
+
#For text files
|
|
20
|
+
|
|
21
|
+
model = EmbeddingModel.from_pretrained_local(
|
|
22
|
+
WhichModel.Bert, model_id="Hugging_face_link"
|
|
23
|
+
)
|
|
24
|
+
data = embed_anything.embed_file("test_files/test.pdf", embeder=model)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
#For images
|
|
28
|
+
model = embed_anything.EmbeddingModel.from_pretrained_local(
|
|
29
|
+
embed_anything.WhichModel.Clip,
|
|
30
|
+
model_id="openai/clip-vit-base-patch16",
|
|
31
|
+
# revision="refs/pr/15",
|
|
32
|
+
)
|
|
33
|
+
data: list[EmbedData] = embed_anything.embed_directory("test_files", embeder=model)
|
|
34
|
+
embeddings = np.array([data.embedding for data in data])
|
|
35
|
+
query = ["Photo of a monkey?"]
|
|
36
|
+
query_embedding = np.array(
|
|
37
|
+
embed_anything.embed_query(query, embeder=model)[0].embedding
|
|
38
|
+
)
|
|
39
|
+
# For audio files
|
|
40
|
+
from embed_anything import (
|
|
41
|
+
AudioDecoderModel,
|
|
42
|
+
EmbeddingModel,
|
|
43
|
+
embed_audio_file,
|
|
44
|
+
TextEmbedConfig,
|
|
45
|
+
)
|
|
46
|
+
# choose any whisper or distilwhisper model from https://huggingface.co/distil-whisper or https://huggingface.co/collections/openai/whisper-release-6501bba2cf999715fd953013
|
|
47
|
+
audio_decoder = AudioDecoderModel.from_pretrained_hf(
|
|
48
|
+
"openai/whisper-tiny.en", revision="main", model_type="tiny-en", quantized=False
|
|
49
|
+
)
|
|
50
|
+
embeder = EmbeddingModel.from_pretrained_hf(
|
|
51
|
+
embed_anything.WhichModel.Bert,
|
|
52
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
53
|
+
revision="main",
|
|
54
|
+
)
|
|
55
|
+
config = TextEmbedConfig(chunk_size=200, batch_size=32)
|
|
56
|
+
data = embed_anything.embed_audio_file(
|
|
57
|
+
"test_files/audio/samples_hp0.wav",
|
|
58
|
+
audio_decoder=audio_decoder,
|
|
59
|
+
embeder=embeder,
|
|
60
|
+
text_embed_config=config,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
You can also store the embeddings to a vector database and not keep them on memory. Here is an example of how to use the `PineconeAdapter` class:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import embed_anything
|
|
69
|
+
import os
|
|
70
|
+
|
|
71
|
+
from embed_anything.vectordb import PineconeAdapter
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Initialize the PineconeEmbedder class
|
|
75
|
+
api_key = os.environ.get("PINECONE_API_KEY")
|
|
76
|
+
index_name = "anything"
|
|
77
|
+
pinecone_adapter = PineconeAdapter(api_key)
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
pinecone_adapter.delete_index("anything")
|
|
81
|
+
except:
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
# Initialize the PineconeEmbedder class
|
|
85
|
+
|
|
86
|
+
pinecone_adapter.create_index(dimension=512, metric="cosine")
|
|
87
|
+
|
|
88
|
+
# bert_model = EmbeddingModel.from_pretrained_hf(
|
|
89
|
+
# WhichModel.Bert, "sentence-transformers/all-MiniLM-L12-v2", revision="main"
|
|
90
|
+
# )
|
|
91
|
+
|
|
92
|
+
clip_model = EmbeddingModel.from_pretrained_hf(
|
|
93
|
+
WhichModel.Clip, "openai/clip-vit-base-patch16", revision="main"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
embed_config = TextEmbedConfig(chunk_size=512, batch_size=32)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
data = embed_anything.embed_image_directory(
|
|
100
|
+
"test_files",
|
|
101
|
+
embeder=clip_model,
|
|
102
|
+
adapter=pinecone_adapter,
|
|
103
|
+
# config=embed_config,
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Supported Embedding Models:
|
|
108
|
+
---------------------------
|
|
109
|
+
- Text Embedding Models:
|
|
110
|
+
- "OpenAI"
|
|
111
|
+
- "Bert"
|
|
112
|
+
- "Jina"
|
|
113
|
+
|
|
114
|
+
- Image Embedding Models:
|
|
115
|
+
- "Clip"
|
|
116
|
+
- "SigLip" (Coming Soon)
|
|
117
|
+
|
|
118
|
+
- Audio Embedding Models:
|
|
119
|
+
- "Whisper"
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
from ._embed_anything import *
|
|
123
|
+
from .vectordb import *
|
|
124
|
+
|
|
125
|
+
__doc__ = _embed_anything.__doc__
|
|
126
|
+
if hasattr(_embed_anything, "__all__"):
|
|
127
|
+
__all__ = _embed_anything.__all__
|
|
Binary file
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import List, Dict
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
class Adapter(ABC):
|
|
6
|
+
def __init__(self, api_key: str): ...
|
|
7
|
+
@abstractmethod
|
|
8
|
+
def create_index(self, dimension: int, metric: str, index_name: str, **kwargs): ...
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def delete_index(self, index_name: str): ...
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def convert(self, embeddings: List[List[EmbedData]]) -> List[Dict]: ...
|
|
13
|
+
@abstractmethod
|
|
14
|
+
def upsert(self, data: List[Dict]): ...
|
|
15
|
+
|
|
16
|
+
def embed_query(
|
|
17
|
+
query: list[str], embeder: EmbeddingModel, config: TextEmbedConfig | None = None
|
|
18
|
+
) -> list[EmbedData]:
|
|
19
|
+
"""
|
|
20
|
+
Embeds the given query and returns a list of EmbedData objects.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
query: The query to embed.
|
|
24
|
+
embeder: The embedding model to use.
|
|
25
|
+
config: The configuration for the embedding model.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
A list of EmbedData objects.
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import embed_anything
|
|
34
|
+
model = embed_anything.EmbeddingModel.from_pretrained_hf(
|
|
35
|
+
embed_anything.WhichModel.Bert,
|
|
36
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
37
|
+
revision="main",
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def embed_file(
|
|
43
|
+
file_path: str,
|
|
44
|
+
embeder: EmbeddingModel,
|
|
45
|
+
config: TextEmbedConfig | None = None,
|
|
46
|
+
adapter: Adapter | None = None,
|
|
47
|
+
) -> list[EmbedData]:
|
|
48
|
+
"""
|
|
49
|
+
Embeds the given file and returns a list of EmbedData objects.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
file_path: The path to the file to embed.
|
|
53
|
+
embeder: The embedding model to use.
|
|
54
|
+
config: The configuration for the embedding model.
|
|
55
|
+
adapter: The adapter to use for storing the embeddings in a vector database.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
A list of EmbedData objects.
|
|
59
|
+
|
|
60
|
+
Example:
|
|
61
|
+
```python
|
|
62
|
+
import embed_anything
|
|
63
|
+
model = embed_anything.EmbeddingModel.from_pretrained_hf(
|
|
64
|
+
embed_anything.WhichModel.Bert,
|
|
65
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
66
|
+
revision="main",
|
|
67
|
+
)
|
|
68
|
+
data = embed_anything.embed_file("test_files/test.pdf", embeder=model)
|
|
69
|
+
```
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
def embed_directory(
|
|
73
|
+
file_path: str,
|
|
74
|
+
embeder: EmbeddingModel,
|
|
75
|
+
extensions: list[str],
|
|
76
|
+
config: TextEmbedConfig | None = None,
|
|
77
|
+
adapter: Adapter | None = None,
|
|
78
|
+
) -> list[EmbedData]:
|
|
79
|
+
"""
|
|
80
|
+
Embeds the files in the given directory and returns a list of EmbedData objects.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
file_path: The path to the directory containing the files to embed.
|
|
84
|
+
embeder: The embedding model to use.
|
|
85
|
+
extensions: The list of file extensions to consider for embedding.
|
|
86
|
+
config: The configuration for the embedding model.
|
|
87
|
+
adapter: The adapter to use for storing the embeddings in a vector database.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
A list of EmbedData objects.
|
|
91
|
+
|
|
92
|
+
Example:
|
|
93
|
+
```python
|
|
94
|
+
import embed_anything
|
|
95
|
+
model = embed_anything.EmbeddingModel.from_pretrained_hf(
|
|
96
|
+
embed_anything.WhichModel.Bert,
|
|
97
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
98
|
+
revision="main",
|
|
99
|
+
)
|
|
100
|
+
data = embed_anything.embed_directory("test_files", embeder=model, extensions=[".pdf"])
|
|
101
|
+
```
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
def embed_image_directory(
|
|
105
|
+
file_path: str,
|
|
106
|
+
embeder: EmbeddingModel,
|
|
107
|
+
config: ImageEmbedConfig | None = None,
|
|
108
|
+
adapter: Adapter | None = None,
|
|
109
|
+
) -> list[EmbedData]:
|
|
110
|
+
"""
|
|
111
|
+
Embeds the images in the given directory and returns a list of EmbedData objects.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
file_path: The path to the directory containing the images to embed.
|
|
115
|
+
embeder: The embedding model to use.
|
|
116
|
+
config: The configuration for the embedding model.
|
|
117
|
+
adapter: The adapter to use for storing the embeddings in a vector database.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
A list of EmbedData objects.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
def embed_webpage(
|
|
124
|
+
url: str,
|
|
125
|
+
embeder: EmbeddingModel,
|
|
126
|
+
config: TextEmbedConfig | None,
|
|
127
|
+
adapter: Adapter | None,
|
|
128
|
+
) -> list[EmbedData] | None:
|
|
129
|
+
"""Embeds the webpage at the given URL and returns a list of EmbedData
|
|
130
|
+
objects.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
url: The URL of the webpage to embed.
|
|
134
|
+
embeder: The name of the embedding model to use. Choose between "OpenAI", "Jina", "Bert"
|
|
135
|
+
config: The configuration for the embedding model.
|
|
136
|
+
adapter: The adapter to use for storing the embeddings.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
A list of EmbedData objects
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
```python
|
|
143
|
+
import embed_anything
|
|
144
|
+
|
|
145
|
+
config = embed_anything.EmbedConfig(
|
|
146
|
+
openai_config=embed_anything.OpenAIConfig(model="text-embedding-3-small")
|
|
147
|
+
)
|
|
148
|
+
data = embed_anything.embed_webpage(
|
|
149
|
+
"https://www.akshaymakes.com/", embeder="OpenAI", config=config
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
def embed_audio_file(
|
|
155
|
+
file_path: str,
|
|
156
|
+
audio_decoder: AudioDecoderModel,
|
|
157
|
+
embeder: EmbeddingModel,
|
|
158
|
+
text_embed_config: TextEmbedConfig | None = TextEmbedConfig(
|
|
159
|
+
chunk_size=200, batch_size=32
|
|
160
|
+
),
|
|
161
|
+
) -> list[EmbedData]:
|
|
162
|
+
"""
|
|
163
|
+
Embeds the given audio file and returns a list of EmbedData objects.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
file_path: The path to the audio file to embed.
|
|
167
|
+
audio_decoder: The audio decoder model to use.
|
|
168
|
+
embeder: The embedding model to use.
|
|
169
|
+
text_embed_config: The configuration for the embedding model.
|
|
170
|
+
|
|
171
|
+
Returns:
|
|
172
|
+
A list of EmbedData objects.
|
|
173
|
+
|
|
174
|
+
Example:
|
|
175
|
+
```python
|
|
176
|
+
|
|
177
|
+
import embed_anything
|
|
178
|
+
audio_decoder = embed_anything.AudioDecoderModel.from_pretrained_hf(
|
|
179
|
+
"openai/whisper-tiny.en", revision="main", model_type="tiny-en", quantized=False
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
embeder = embed_anything.EmbeddingModel.from_pretrained_hf(
|
|
183
|
+
embed_anything.WhichModel.Bert,
|
|
184
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
185
|
+
revision="main",
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
config = embed_anything.TextEmbedConfig(chunk_size=200, batch_size=32)
|
|
189
|
+
data = embed_anything.embed_audio_file(
|
|
190
|
+
"test_files/audio/samples_hp0.wav",
|
|
191
|
+
audio_decoder=audio_decoder,
|
|
192
|
+
embeder=embeder,
|
|
193
|
+
text_embed_config=config,
|
|
194
|
+
)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
class EmbedData:
|
|
200
|
+
"""Represents the data of an embedded file.
|
|
201
|
+
|
|
202
|
+
Attributes:
|
|
203
|
+
embedding: The embedding of the file.
|
|
204
|
+
text: The text for which the embedding is generated for.
|
|
205
|
+
metadata: Additional metadata associated with the embedding.
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
def __init__(self, embedding: list[float], text: str, metadata: dict[str, str]):
|
|
209
|
+
self.embedding = embedding
|
|
210
|
+
self.text = text
|
|
211
|
+
self.metadata = metadata
|
|
212
|
+
embedding: list[float]
|
|
213
|
+
text: str
|
|
214
|
+
metadata: dict[str, str]
|
|
215
|
+
|
|
216
|
+
class TextEmbedConfig:
|
|
217
|
+
"""
|
|
218
|
+
Represents the configuration for the Text Embedding model.
|
|
219
|
+
|
|
220
|
+
Attributes:
|
|
221
|
+
chunk_size: The chunk size for the Text Embedding model.
|
|
222
|
+
batch_size: The batch size for processing the embeddings. Default is 32. Based on the memory, you can increase or decrease the batch size.
|
|
223
|
+
splitting_strategy: The strategy to use for splitting the text into chunks. Default is "sentence".
|
|
224
|
+
semantic_encoder: The semantic encoder for the Text Embedding model. Default is None.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
def __init__(self, chunk_size: int | None = 256, batch_size: int | None = 32, splitting_strategy: str | None = "sentence", semantic_encoder: EmbeddingModel | None = None):
|
|
228
|
+
self.chunk_size = chunk_size
|
|
229
|
+
self.batch_size = batch_size
|
|
230
|
+
self.splitting_strategy = splitting_strategy
|
|
231
|
+
self.semantic_encoder = semantic_encoder
|
|
232
|
+
chunk_size: int | None
|
|
233
|
+
batch_size: int | None
|
|
234
|
+
splitting_strategy: str | None
|
|
235
|
+
semantic_encoder: EmbeddingModel | None
|
|
236
|
+
|
|
237
|
+
class ImageEmbedConfig:
|
|
238
|
+
"""
|
|
239
|
+
Represents the configuration for the Image Embedding model.
|
|
240
|
+
|
|
241
|
+
Attributes:
|
|
242
|
+
buffer_size: The buffer size for the Image Embedding model. Default is 100.
|
|
243
|
+
"""
|
|
244
|
+
|
|
245
|
+
def __init__(self, buffer_size: int | None = None):
|
|
246
|
+
self.buffer_size = buffer_size
|
|
247
|
+
buffer_size: int | None
|
|
248
|
+
|
|
249
|
+
class EmbeddingModel:
|
|
250
|
+
"""
|
|
251
|
+
Represents an embedding model.
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
"""
|
|
255
|
+
Loads an embedding model from the Hugging Face model hub.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
model_id: The ID of the model.
|
|
259
|
+
revision: The revision of the model.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
An EmbeddingModel object.
|
|
263
|
+
|
|
264
|
+
Example:
|
|
265
|
+
```python
|
|
266
|
+
model = EmbeddingModel.from_pretrained_hf(
|
|
267
|
+
model_id="prithivida/miniMiracle_te_v1",
|
|
268
|
+
revision="main"
|
|
269
|
+
)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
"""
|
|
273
|
+
def from_pretrained_hf(
|
|
274
|
+
model: WhichModel, model_id: str, revision: str | None = None
|
|
275
|
+
) -> EmbeddingModel: ...
|
|
276
|
+
|
|
277
|
+
"""
|
|
278
|
+
Loads an embedding model from a cloud-based service.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
model (WhichModel): The cloud service to use. Currently supports WhichModel.OpenAI and WhichModel.Cohere.
|
|
282
|
+
model_id (str): The ID of the model to use.
|
|
283
|
+
- For OpenAI, see available models at https://platform.openai.com/docs/guides/embeddings/embedding-models
|
|
284
|
+
- For Cohere, see available models at https://docs.cohere.com/docs/cohere-embed
|
|
285
|
+
api_key (str | None, optional): The API key for accessing the model. If not provided, it is taken from the environment variable:
|
|
286
|
+
- For OpenAI: OPENAI_API_KEY
|
|
287
|
+
- For Cohere: CO_API_KEY
|
|
288
|
+
|
|
289
|
+
Returns:
|
|
290
|
+
EmbeddingModel: An initialized EmbeddingModel object.
|
|
291
|
+
|
|
292
|
+
Raises:
|
|
293
|
+
ValueError: If an unsupported model is specified.
|
|
294
|
+
|
|
295
|
+
Example:
|
|
296
|
+
```python
|
|
297
|
+
# Using Cohere
|
|
298
|
+
model = EmbeddingModel.from_pretrained_cloud(
|
|
299
|
+
model=WhichModel.Cohere,
|
|
300
|
+
model_id="embed-english-v3.0"
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
# Using OpenAI
|
|
304
|
+
model = EmbeddingModel.from_pretrained_cloud(
|
|
305
|
+
model=WhichModel.OpenAI,
|
|
306
|
+
model_id="text-embedding-3-small"
|
|
307
|
+
)
|
|
308
|
+
```
|
|
309
|
+
"""
|
|
310
|
+
def from_pretrained_cloud(
|
|
311
|
+
model: WhichModel, model_id: str, api_key: str | None = None
|
|
312
|
+
) -> EmbeddingModel: ...
|
|
313
|
+
|
|
314
|
+
class AudioDecoderModel:
|
|
315
|
+
"""
|
|
316
|
+
Represents an audio decoder model.
|
|
317
|
+
|
|
318
|
+
Attributes:
|
|
319
|
+
model_id: The ID of the audio decoder model.
|
|
320
|
+
revision: The revision of the audio decoder model.
|
|
321
|
+
model_type: The type of the audio decoder model.
|
|
322
|
+
quantized: A flag indicating whether the audio decoder model is quantized or not.
|
|
323
|
+
|
|
324
|
+
Example:
|
|
325
|
+
```python
|
|
326
|
+
|
|
327
|
+
model = embed_anything.AudioDecoderModel.from_pretrained_hf(
|
|
328
|
+
model_id="openai/whisper-tiny.en",
|
|
329
|
+
revision="main",
|
|
330
|
+
model_type="tiny-en",
|
|
331
|
+
quantized=False
|
|
332
|
+
)
|
|
333
|
+
```
|
|
334
|
+
"""
|
|
335
|
+
|
|
336
|
+
model_id: str
|
|
337
|
+
revision: str
|
|
338
|
+
model_type: str
|
|
339
|
+
quantized: bool
|
|
340
|
+
|
|
341
|
+
def from_pretrained_hf(
|
|
342
|
+
model_id: str | None = None,
|
|
343
|
+
revision: str | None = None,
|
|
344
|
+
model_type: str | None = None,
|
|
345
|
+
quantized: bool | None = None,
|
|
346
|
+
): ...
|
|
347
|
+
|
|
348
|
+
class WhichModel(Enum):
|
|
349
|
+
OpenAI = ("OpenAI",)
|
|
350
|
+
Cohere = ("Cohere",)
|
|
351
|
+
Bert = ("Bert",)
|
|
352
|
+
Jina = ("Jina",)
|
|
353
|
+
Clip = ("Clip",)
|
|
Binary file
|
embed_anything/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import uuid
|
|
4
|
+
from typing import List, Dict
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from ._embed_anything import EmbedData
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Adapter(ABC):
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
self.api_key = api_key
|
|
12
|
+
|
|
13
|
+
@abstractmethod
|
|
14
|
+
def create_index(self, dimension: int, metric: str, index_name: str, **kwargs):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def delete_index(self, index_name: str):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def convert(self, embeddings: List[EmbedData]) -> List[Dict]:
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def upsert(self, data: List[Dict]):
|
|
27
|
+
data = self.convert(data)
|
|
28
|
+
pass
|
|
29
|
+
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: embed_anything_gpu
|
|
3
|
+
Version: 0.4.4
|
|
4
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Summary: Embed anything at lightning speed
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
+
Project-URL: Homepage, https://github.com/StarlightSearch/EmbedAnything/tree/main
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<p align ="center">
|
|
19
|
+
<img width=400 src = "https://res.cloudinary.com/dltwftrgc/image/upload/v1712504276/Projects/EmbedAnything_500_x_200_px_a4l8xu.png">
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
|
|
26
|
+
[](https://pepy.tech/project/embed-anything)
|
|
27
|
+
[](https://colab.research.google.com/drive/1CowJrqZxDDYJzkclI-rbHaZHgL9C6K3p?usp=sharing)
|
|
28
|
+
[](https://opensource.org/licenses/Apache2.0)
|
|
29
|
+
[](https://pypi.org/project/embed-anything/)
|
|
30
|
+
[](https://discord.gg/juETVTMdZu)
|
|
31
|
+
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<div align="center">
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<b>Generate and stream your embeddings with minimalist and lightning fast framework built in rust 🦀</b>
|
|
39
|
+
<br />
|
|
40
|
+
<a href="https://starlightsearch.github.io/EmbedAnything/references/"><strong>Explore the docs »</strong></a>
|
|
41
|
+
<br />
|
|
42
|
+
<br />
|
|
43
|
+
<a href=https://youtu.be/HLXIuznnXcI>View Demo</a>
|
|
44
|
+
·
|
|
45
|
+
<a href="https://github.com/StarlightSearch/EmbedAnything/tree/main/examples">Examples</a>
|
|
46
|
+
·
|
|
47
|
+
<a href="https://github.com/StarlightSearch/EmbedAnything/tree/main/examples/adapters">Vector Streaming Adapters</a>
|
|
48
|
+
.
|
|
49
|
+
<a href="https://huggingface.co/spaces/akshayballal/search_in_audio">Search in Audio Space</a>
|
|
50
|
+
|
|
51
|
+
</p>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
EmbedAnything is a minimalist yet highly performant, lightweight, lightening fast, multisource, multimodal and local embedding pipeline, built in rust. Whether you're working with text, images, audio, PDFs, websites, or other media, EmbedAnything simplifies the process of generating embeddings from various sources and streaming them to a vector database.
|
|
56
|
+
|
|
57
|
+
<!-- TABLE OF CONTENTS -->
|
|
58
|
+
<details>
|
|
59
|
+
<summary>Table of Contents</summary>
|
|
60
|
+
<ol>
|
|
61
|
+
<li>
|
|
62
|
+
<a href="#about-the-project">About The Project</a>
|
|
63
|
+
<ul>
|
|
64
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#the-benefit-of-rust-for-speed">Built With Rust</a></li>
|
|
65
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#why-candle">Why Candle?</a></li>
|
|
66
|
+
</ul>
|
|
67
|
+
</li>
|
|
68
|
+
<li>
|
|
69
|
+
<a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#-getting-started">Getting Started</a>
|
|
70
|
+
<ul>
|
|
71
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#-installation">Installation</a></li>
|
|
72
|
+
</ul>
|
|
73
|
+
</li>
|
|
74
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#-getting-started">Usage</a></li>
|
|
75
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#roadmap">Roadmap</a></li>
|
|
76
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#quick-start">Contributing</a></li>
|
|
77
|
+
<li><a href="https://github.com/StarlightSearch/EmbedAnything?tab=readme-ov-file#Supported-Models">How to add custom model and chunk size</a></li>
|
|
78
|
+
|
|
79
|
+
</ol>
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## 🚀 Key Features
|
|
86
|
+
|
|
87
|
+
- **Local Embedding** : Works with local embedding models like BERT and JINA
|
|
88
|
+
- **Cloud Embedding Models:**: Supports OpenAI. Mistral and Cohere Support coming soon.
|
|
89
|
+
- **MultiModality** : Works with text sources like PDFs, txt, md, Images JPG and Audio, .WAV
|
|
90
|
+
- **Rust** : All the file processing is done in rust for speed and efficiency
|
|
91
|
+
- **Candle** : We have taken care of hardware acceleration as well, with Candle.
|
|
92
|
+
- **Python Interface:** Packaged as a Python library for seamless integration into your existing projects.
|
|
93
|
+
- **Scalable:** Store embeddings in a vector database for easy retrieval and scalability.
|
|
94
|
+
- **Vector Streaming:** Continuously create and stream embeddings if you have low resource.
|
|
95
|
+
|
|
96
|
+
## 💡What is Vector Streaming
|
|
97
|
+
|
|
98
|
+
Vector Streaming enables you to process and generate embeddings for files and stream them, so if you have 10 GB of file, it can continuously generate embeddings file by file (Or chunk by chunk in future) and store them in the vector database of your choice, Thus it eliminates bulk embeddings storage on RAM at once.
|
|
99
|
+
|
|
100
|
+
[](https://www.youtube.com/watch?v=OJRWPLQ44Dw)
|
|
101
|
+
|
|
102
|
+
## 🦀 Why Embed Anything
|
|
103
|
+
|
|
104
|
+
➡️Faster execution. <br />
|
|
105
|
+
➡️Memory Management: Rust enforces memory management simultaneously, preventing memory leaks and crashes that can plague other languages <br />
|
|
106
|
+
➡️True multithreading <br />
|
|
107
|
+
➡️Running language models or embedding models locally and efficiently <br />
|
|
108
|
+
➡️Candle allows inferences on CUDA-enabled GPUs right out of the box. <br />
|
|
109
|
+
➡️Decrease the memory usage of EmbedAnything.
|
|
110
|
+
|
|
111
|
+
# ⭐ Supported Models
|
|
112
|
+
|
|
113
|
+
We support a range of models, that can be supported by Candle, We have given a set of tested models but if you have specific usecase do mention it in the issue.
|
|
114
|
+
|
|
115
|
+
## How to add custom model and Chunk Size.
|
|
116
|
+
```python
|
|
117
|
+
model = EmbeddingModel.from_pretrained_hf(
|
|
118
|
+
WhichModel.Bert, model_id="model link from huggingface"
|
|
119
|
+
)
|
|
120
|
+
config = TextEmbedConfig(chunk_size=200, batch_size=32)
|
|
121
|
+
data = embed_anything.embed_file("file_address", embeder=model, config=config)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
| Model | Custom link |
|
|
126
|
+
| ------------- | ------------- |
|
|
127
|
+
| Jina | jinaai/jina-embeddings-v2-base-en |
|
|
128
|
+
| | jinaai/jina-embeddings-v2-small-en |
|
|
129
|
+
| Bert | sentence-transformers/all-MiniLM-L6-v2 |
|
|
130
|
+
| | sentence-transformers/all-MiniLM-L12-v2 |
|
|
131
|
+
| | sentence-transformers/paraphrase-MiniLM-L6-v2 |
|
|
132
|
+
| Clip | openai/clip-vit-base-patch32 |
|
|
133
|
+
| Whisper| Most OpenAI Whisper from huggingface supported.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# 🧑🚀 Getting Started
|
|
139
|
+
|
|
140
|
+
## 💚 Installation
|
|
141
|
+
|
|
142
|
+
`
|
|
143
|
+
pip install embed-anything`
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# Usage
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## ➡️ Usage For 0.3 and later version
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
### To use local embedding: we support Bert and Jina
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
model = EmbeddingModel.from_pretrained_local(
|
|
157
|
+
WhichModel.Bert, model_id="Hugging_face_link"
|
|
158
|
+
)
|
|
159
|
+
data = embed_anything.embed_file("test_files/test.pdf", embeder=model)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## For multimodal embedding: we support CLIP
|
|
165
|
+
### Requirements Directory with pictures you want to search for example we have test_files with images of cat, dogs etc
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import embed_anything
|
|
169
|
+
from embed_anything import EmbedData
|
|
170
|
+
model = embed_anything.EmbeddingModel.from_pretrained_local(
|
|
171
|
+
embed_anything.WhichModel.Clip,
|
|
172
|
+
model_id="openai/clip-vit-base-patch16",
|
|
173
|
+
# revision="refs/pr/15",
|
|
174
|
+
)
|
|
175
|
+
data: list[EmbedData] = embed_anything.embed_directory("test_files", embeder=model)
|
|
176
|
+
embeddings = np.array([data.embedding for data in data])
|
|
177
|
+
query = ["Photo of a monkey?"]
|
|
178
|
+
query_embedding = np.array(
|
|
179
|
+
embed_anything.embed_query(query, embeder=model)[0].embedding
|
|
180
|
+
)
|
|
181
|
+
similarities = np.dot(embeddings, query_embedding)
|
|
182
|
+
max_index = np.argmax(similarities)
|
|
183
|
+
Image.open(data[max_index].text).show()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Audio Embedding using Whisper
|
|
187
|
+
### requirements: Audio .wav files.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
import embed_anything
|
|
192
|
+
from embed_anything import (
|
|
193
|
+
AudioDecoderModel,
|
|
194
|
+
EmbeddingModel,
|
|
195
|
+
embed_audio_file,
|
|
196
|
+
TextEmbedConfig,
|
|
197
|
+
)
|
|
198
|
+
# choose any whisper or distilwhisper model from https://huggingface.co/distil-whisper or https://huggingface.co/collections/openai/whisper-release-6501bba2cf999715fd953013
|
|
199
|
+
audio_decoder = AudioDecoderModel.from_pretrained_hf(
|
|
200
|
+
"openai/whisper-tiny.en", revision="main", model_type="tiny-en", quantized=False
|
|
201
|
+
)
|
|
202
|
+
embeder = EmbeddingModel.from_pretrained_hf(
|
|
203
|
+
embed_anything.WhichModel.Bert,
|
|
204
|
+
model_id="sentence-transformers/all-MiniLM-L6-v2",
|
|
205
|
+
revision="main",
|
|
206
|
+
)
|
|
207
|
+
config = TextEmbedConfig(chunk_size=200, batch_size=32)
|
|
208
|
+
data = embed_anything.embed_audio_file(
|
|
209
|
+
"test_files/audio/samples_hp0.wav",
|
|
210
|
+
audio_decoder=audio_decoder,
|
|
211
|
+
embeder=embeder,
|
|
212
|
+
text_embed_config=config,
|
|
213
|
+
)
|
|
214
|
+
print(data[0].metadata)
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## ➡️ Usage For 0.2
|
|
219
|
+
|
|
220
|
+
### To use local embedding: we support Bert and Jina
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
import embed_anything
|
|
224
|
+
data = embed_anything.embed_file("file_path.pdf", embeder= "Bert")
|
|
225
|
+
embeddings = np.array([data.embedding for data in data])
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## For multimodal embedding: we support CLIP
|
|
231
|
+
### Requirements Directory with pictures you want to search for example we have test_files with images of cat, dogs etc
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
import embed_anything
|
|
235
|
+
data = embed_anything.embed_directory("directory_path", embeder= "Clip")
|
|
236
|
+
embeddings = np.array([data.embedding for data in data])
|
|
237
|
+
|
|
238
|
+
query = ["photo of a dog"]
|
|
239
|
+
query_embedding = np.array(embed_anything.embed_query(query, embeder= "Clip")[0].embedding)
|
|
240
|
+
similarities = np.dot(embeddings, query_embedding)
|
|
241
|
+
max_index = np.argmax(similarities)
|
|
242
|
+
Image.open(data[max_index].text).show()
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Audio Embedding using Whisper
|
|
246
|
+
### requirements: Audio .wav files.
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
import embed_anything
|
|
251
|
+
from embed_anything import JinaConfig, EmbedConfig, AudioDecoderConfig
|
|
252
|
+
import time
|
|
253
|
+
|
|
254
|
+
start_time = time.time()
|
|
255
|
+
|
|
256
|
+
# choose any whisper or distilwhisper model from https://huggingface.co/distil-whisper or https://huggingface.co/collections/openai/whisper-release-6501bba2cf999715fd953013
|
|
257
|
+
audio_decoder_config = AudioDecoderConfig(
|
|
258
|
+
decoder_model_id="openai/whisper-tiny.en",
|
|
259
|
+
decoder_revision="main",
|
|
260
|
+
model_type="tiny-en",
|
|
261
|
+
quantized=False,
|
|
262
|
+
)
|
|
263
|
+
jina_config = JinaConfig(
|
|
264
|
+
model_id="jinaai/jina-embeddings-v2-small-en", revision="main", chunk_size=100
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
config = EmbedConfig(jina=jina_config, audio_decoder=audio_decoder_config)
|
|
268
|
+
data = embed_anything.embed_file(
|
|
269
|
+
"test_files/audio/samples_hp0.wav", embeder="Audio", config=config
|
|
270
|
+
)
|
|
271
|
+
print(data[0].metadata)
|
|
272
|
+
end_time = time.time()
|
|
273
|
+
print("Time taken: ", end_time - start_time)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
## 🚧 Contributing to EmbedAnything
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
First of all, thank you for taking the time to contribute to this project. We truly appreciate your contributions, whether it's bug reports, feature suggestions, or pull requests. Your time and effort are highly valued in this project. 🚀
|
|
289
|
+
|
|
290
|
+
This document provides guidelines and best practices to help you to contribute effectively. These are meant to serve as guidelines, not strict rules. We encourage you to use your best judgment and feel comfortable proposing changes to this document through a pull request.
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
<li><a href="##-RoadMap">Roadmap</a></li>
|
|
295
|
+
<li><a href="##-Quick-Start">Quick Start</a></li>
|
|
296
|
+
<li><a href="##-Contributing-Guidelines">Guidelines</a></li>
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
## RoadMap
|
|
300
|
+
One of the aims of EmbedAnything is to allow AI engineers to easily use state of the art embedding models on typical files and documents. A lot has already been accomplished here and these are the formats that we support right now and a few more have to be done. <br />
|
|
301
|
+
✅ Markdown, PDFs, and Website <br />
|
|
302
|
+
✅ WAV File <br />
|
|
303
|
+
✅ JPG, PNG, webp <br />
|
|
304
|
+
✅Add whisper for audio embeddings <br />
|
|
305
|
+
✅Custom model upload, anything that is available in candle <br />
|
|
306
|
+
✅Custom chunk size <br />
|
|
307
|
+
✅Pinecone Adapter, to directly save it on it. <br />
|
|
308
|
+
✅Zero-shot application <br />
|
|
309
|
+
✅Vector database integration via streaming adapters <br />
|
|
310
|
+
✅Refactoring for intuitive functions
|
|
311
|
+
|
|
312
|
+
Yet to do be done <br />
|
|
313
|
+
☑️Introducing chunkwise streaming instead of file <br />
|
|
314
|
+
☑️Graph embedding -- build deepwalks embeddings depth first and word to vec <br />
|
|
315
|
+
☑️Video Embedding
|
|
316
|
+
☑️ Yolo Clip
|
|
317
|
+
☑️ Add more Vector Database Adapters
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
embed_anything_gpu-0.4.4.dist-info/METADATA,sha256=BXlrnUmQ0gEaZ94ibnG0yVPld3y_RMrGf7t5R8-RDuI,11952
|
|
2
|
+
embed_anything_gpu-0.4.4.dist-info/WHEEL,sha256=lTVQXmazV4_utY20nrWmfqVmjb3H_3iP6bNgox5pvtU,94
|
|
3
|
+
embed_anything_gpu-0.4.4.dist-info/license_files/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
+
embed_anything/libiomp5md.dll,sha256=CtcfRm0RXTU9zpS6MrY-KI9IGY6J9VHUbczkYf7b0ZU,2047000
|
|
5
|
+
embed_anything/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
embed_anything/vectordb.py,sha256=JxONVbTppiGvUW9J7eCoN0SCHYTyXuABWHZRgo6HneY,634
|
|
7
|
+
embed_anything/_embed_anything.pyi,sha256=cUkrswJhft5k7A0Muj-e1x1AGeWClpSK3UKeZ5FrC-I,10633
|
|
8
|
+
embed_anything/__init__.py,sha256=yOTiUWa3fyByvlbjDB1IQ1J-2wsyYq-P06c8Aoik1DE,3554
|
|
9
|
+
embed_anything/_embed_anything.cp38-win_amd64.pyd,sha256=19jNXKIwIzJbDi0-foPgldqcBz0icqAMUe4Br1I6tQo,34092544
|
|
10
|
+
embed_anything_gpu-0.4.4.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|