This README provides comprehensive guidance on setting up, running, and using the Embedding Service. The service leverages advanced AI models for text labeling and embedding, making it ideal for machine learning applications that require high-quality text representation.
The Embedding Service is a gRPC-based service designed to:
- Label Text: Generate meaningful labels using GPT-3.5 Turbo.
- Generate Embeddings: Convert labeled text into efficient vector representations using Text-Embedding-Small-3.
- JSON Integration: Deliver labeled and embedded data in a structured JSON format.
- Real-Time API: Enable real-time data streaming using a gRPC server for seamless integration with other systems.
-
Text Labeling:
- Uses GPT-3.5 Turbo for generating descriptive labels for input text.
- Enhances the interpretability of raw text data.
-
Text Embedding:
- Converts labeled data into embeddings with Text-Embedding-Small-3.
- Provides high-dimensional vector representations for downstream tasks like clustering, classification, and search.
-
JSON Output:
- Structured output includes both the text labels and embeddings in an easily consumable JSON format.
-
gRPC Server:
- Offers a real-time API to stream JSON responses.
- Designed for scalability and integration with client applications.
-
Python Environment:
- Python 3.8 or higher is recommended.
- Install virtualenv for managing dependencies.
-
gRPC Tools:
- Ensure
grpcioandgrpcio-toolsare installed for generating and running gRPC services.
- Ensure
-
System Requirements:
- Memory: At least 4GB of RAM.
- Disk Space: 10GB available space for dependencies and logs.
-
Clone the Repository:
git clone https://github.com/your-repository/embedding-service.git cd embedding-service -
Set Up Virtual Environment:
python3 -m venv venv source venv/bin/activate # For Linux/MacOS venv\Scripts\activate # For Windows
-
Install Dependencies: Install all necessary libraries from
requirements.txt:pip install -r requirements.txt
-
Generate gRPC Code: If changes have been made to the
.protofile, regenerate the gRPC stubs:python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. modules/proto/embedding_service.proto
-
Start the gRPC Server: Launch the server to handle incoming gRPC requests:
python server.py
Output:
Server started, listening on port 50051. -
Test the Service: Run the provided client or use a custom client to send requests. Example:
python client.py
The Embedding Service accepts a text file as input and returns labeled and embedded data in JSON format via gRPC.
- Prepare a text file (e.g.,
example.txt) containing the raw text data. - Send the file path via the gRPC client.
- Receive a JSON stream response with:
- Labels: Generated by GPT-3.5 Turbo.
- Embeddings: Produced by Text-Embedding-Small-3.
Example JSON Response:
{
"definition": {
"collection_name": "example_collection",
"partition_name": "example_partition",
"description": "A sample text file",
"dimension": 128,
"metric_type": "L2"
},
"embeddings": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
}server.py: Starts the gRPC server.client.py: Example client to test the service.modules/:proto/: Contains the.protofile and generated gRPC stubs.services/: Contains theLabelerandEmbeddingGeneratorlogic.template.py: Handles JSON template creation and validation.
-
gRPC Not Found:
- Ensure
grpcioandgrpcio-toolsare installed:pip install grpcio grpcio-tools
- Ensure
-
Serialization Errors:
- Ensure the server is returning the correct response type defined in the
.protofile.
- Ensure the server is returning the correct response type defined in the
-
Port Already in Use:
- Check if another service is running on port 50051:
lsof -i:50051 # For Linux/MacOS netstat -ano | findstr :50051 # For Windows
- Check if another service is running on port 50051:
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.