📄
HosonoDE/EasyAI-PHP
  • Introduction: EasyAI-PHP
  • 💬OpenAIChat
    • OpenAIChat
  • ↔️Embedding
    • EmbeddingGenerator
  • 🌲Pinecone
    • PineconeVectorStore
  • 🕷️Crawler
    • Server Client vs Zyte API
    • How to start with Crawler & ZyteCrawler
      • Using the CrawlerConfig
      • Using the ZyteConfig
  • 🛠️Tools
    • Basic Usage
  • 📜Other Pages
    • Interesting Links
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Embedding

EmbeddingGenerator

PreviousOpenAIChatNextPineconeVectorStore

Last updated 1 year ago

Was this helpful?

Usage of EmbeddingGenerator\OpenAI

Explanation of Embedding

An "embedding" is a vector representation of text that captures semantic meanings of the words or phrases. These vectors are generated by deep learning models and can be used in machine learning applications to compare texts, search for similar content, or feed into other machine learning models for tasks like classification or clustering. Each component of the vector represents a dimension of the text's meaning, allowing the model to understand and process text similarly to how humans do but in a numerical form.

Usage of EmbeddingGenerator\OpenAI This section covers the different classes available for generating embeddings using OpenAI models. Below is a table summarizing the key details of each available class.

Class
Model
Embedding size

OpenAIADA002EmbeddingGenerator

text-embedding-ada-002

1536

OpenAI3SmallEmbeddingGenerator

text-embedding-3-small

1536

OpenAI3LargeEmbeddingGenerator

text-embedding-3-large

3072

Source:

Using the right class to pick one of the models:

use EasyAI\Embeddings\EmbeddingGenerator\OpenAI\OpenAI3SmallEmbeddingGenerator; // Using OpenAI3SmallEmbeddingGenerator

// Embedding
$embeddingGenerator = new OpenAI3SmallEmbeddingGenerator();
$embedding = $embeddingGenerator->embedText('Your text string to embed');
↔️
↔️
https://platform.openai.com/docs/guides/embeddings