# text-embedding-3-large

Source: https://zilliz.com/ai-models/text-embedding-3-large
Published: 2024-07-25T16:00:17.195Z

## Model attributes

| Attribute | Value |
| --- | --- |
| Provider | OpenAI |
| Integration | Milvus & Zilliz Cloud Integrated |
| Task | Embedding |
| Modality | Text |
| Similarity metric | Any (Normalized) |
| License | Proprietary |
| Dimensions | 3072 |
| Max input tokens | 8191 |
| Price | $0.13/1M tokens |

## Introduction to text-embedding-3-large 

`text-embedding-3-large` is OpenAI’s large text embedding model, creating embeddings with up to 3072 dimensions. Compared to OpenAI’s other text embedding models, such as `text-embedding-ada-002` and `text-embedding-3-large`, `text-embedding-3-large` has stronger performance and reduced prices.

Let’s take a quick look at some basics.

| Model                                 | Dimensions | Max Tokens | Model MIRACL avg | METB avg | Price                        |
| ----------------------------- | --------------- | -------------- | ---------------------- | ------------ | ---------------------- |
| text-embedding-3-large   | 3072             | 8191           | 54.9                           | 64.6          | $0.13 / 1M tokens |
| [text-embedding-ada-002](https://zilliz.com/ai-models/text-embedding-ada-002) | 1536             | 8191           | 31.4                           | 61.0          | $0.10 / 1M tokens |
| [text-embedding-3-small](https://zilliz.com/ai-models/text-embedding-3-small)   | 1536             | 8191           | 44.0                           | 62.3          | $0.02 / 1M tokens |

## How to generate vector embeddings with the text-embedding-3-large model

There are two primary ways to create vector embeddings:

- [**PyMilvus**](https://github.com/milvus-io/pymilvus): the Python SDK for [Milvus](https://zilliz.com/what-is-milvus) that seamlessly integrates the `text-embedding-3-large` model. 
- **OpenAI Embedding**: the Python SDK offered by OpenAI. 


Once the vector embeddings are generated, they can be stored in [Zilliz Cloud](https://zilliz.com/cloud) (a fully managed vector database service powered by Milvus) and used for [semantic similarity search](https://zilliz.com/glossary/semantic-search). Here are four key steps:

1. [**Sign up**](https://cloud.zilliz.com/signup) for a Zilliz Cloud account for free.
2. **[Set up a serverless cluster](https://docs.zilliz.com/docs/create-cluster#set-up-a-free-cluster)** and obtain the [Public Endpoint and API Key](https://docs.zilliz.com/docs/on-zilliz-cloud-console#free-cluster-details).
3. **Create a vector collection** and insert your vector embeddings.
4. **Run a semantic search** on the stored embeddings.



### Generate vector embeddings via PyMilvus and insert them into Zilliz Cloud for semantic search


```
from pymilvus.model.dense import OpenAIEmbeddingFunction
from pymilvus import MilvusClient

OPENAI_API_KEY = "your-openai-api-key"
ef = OpenAIEmbeddingFunction("text-embedding-3-large", api_key=OPENAI_API_KEY)

docs = [
   "Artificial intelligence was founded as an academic discipline in 1956.",
   "Alan Turing was the first person to conduct substantial research in AI.",
   "Born in Maida Vale, London, Turing was raised in southern England."
]
# Generate embeddings for documents
docs_embeddings = ef(docs)

queries = ["When was artificial intelligence founded",
          "Where was Alan Turing born?"]
# Generate embeddings for queries
query_embeddings = ef(queries)

# Connect to Zilliz Cloud with Public Endpoint and API Key
client = MilvusClient(
    uri=ZILLIZ_PUBLIC_ENDPOINT,
    token=ZILLIZ_API_KEY)

COLLECTION = "documents"
if client.has_collection(collection_name=COLLECTION):
    client.drop_collection(collection_name=COLLECTION)
client.create_collection(
    collection_name=COLLECTION,
    dimension=ef.dim,
    auto_id=True)

for doc, embedding in zip(docs, docs_embeddings):
    client.insert(COLLECTION, {"text": doc, "vector": embedding})
    
results = client.search(
    collection_name=COLLECTION,
    data=query_embeddings,
    consistency_level="Strong",
    output_fields=["text"])
```


For more information, refer to our [PyMilvus Embedding Model documentation](https://milvus.io/docs/embeddings.md). 


### Generate vector embeddings via OpenAI’s Python SDK and insert them into Zilliz Cloud for semantic search

```
from openai import OpenAI
from pymilvus import MilvusClient

OPENAI_API_KEY = "your-openai-api-key"
client = OpenAI(api_key=OPENAI_API_KEY)
# Generate embeddings for documents
doc_response = client.embeddings.create(
   input=[
   "Artificial intelligence was founded as an academic discipline in 1956.",
   "Alan Turing was the first person to conduct substantial research in AI.",
   "Born in Maida Vale, London, Turing was raised in southern England."
   ],
   model="text-embedding-3-large"
   )
doc_embeddings = [data.embedding for data in doc_response.data]

# Generate embeddings for queries
query_response = client.embeddings.create(
   input=["When was artificial intelligence founded",
          "Where was Alan Turing born?"],
   model="text-embedding-3-large"
   )
query_embeddings = [data.embedding for data in query_response.data]

# Connect to Zilliz Cloud with Public Endpoint and API Key
client = MilvusClient(
    uri=ZILLIZ_PUBLIC_ENDPOINT,
    token=ZILLIZ_API_KEY)

COLLECTION = "documents"
if client.has_collection(collection_name=COLLECTION):
    client.drop_collection(collection_name=COLLECTION)
client.create_collection(
    collection_name=COLLECTION,
    dimension=3072,
    auto_id=True)

for doc, embedding in zip(docs, docs_embeddings):
    client.insert(COLLECTION, {"text": doc, "vector": embedding})
    
results = client.search(
    collection_name=COLLECTION,
    data=query_embeddings,
    consistency_level="Strong",
    output_fields=["text"])
``` 


For more information, refer to [OpenAI’s Embedding Guide](https://platform.openai.com/docs/guides/embeddings).
