sb2bg / 8bit-auto-embeddings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

8Bit Auto Embeddings

Description

The 8Bit Auto Embeddings repository contains the backend and machine learning embeddings components used in the 8Bit Auto web application. It uses FastAPI for creating a RESTful API and ChromaDB for managing and querying embedded data.

Features

  • FastAPI for efficient and easy-to-document API routes.
  • ChromaDB integration for persistent storage of embedding vectors.
  • Sentence-Transformer models for generating embeddings from text data.

Getting Started

These instructions will guide you through setting up the project locally for development and testing.

Prerequisites
  • Python 3.8+
  • FastAPI
  • Uvicorn (ASGI server)
  • ChromaDB
  • Sentence Transformers
Installation
  1. Clone the repository:
    git clone https://github.com/sb2bg/8bit-auto-embeddings.git
  2. Navigate to the project directory:
    cd 8bit-auto-embeddings
  3. Install the required Python packages:
    pip install -r requirements.txt
Running the API Server
  1. Start the Uvicorn server:
    uvicorn main:app --reload
    The server will run on http://127.0.0.1:8000 and is accessible via browser or API testing tools like Postman.

Generating Embeddings

To generate embeddings using chroma_embedder.py, follow these steps:

  1. Ensure data.csv is in the repository root, formatted with any columns, as long as it includes excerpt, which is the text data to be embedded.
  2. Run chroma_embedder.py:
    python chroma_embedder.py
    This script uses the SentenceTransformer model to convert titles from data.csv into embeddings, storing them in a ChromaDB collection named cars which is persisted in the chroma.db folder.

API Documentation

Once the server is running, you can access the API documentation automatically generated by FastAPI at http://127.0.0.1:8000/docs. This documentation provides interactive endpoints where you can test the API functionalities directly.

However, the following endpoints are available:

  • GET /chat/{car_str} or /chat/{car_str}?n_results={n_results}
    • Description: Retrieve the n_results (default 5) nearest embedding vector for a given car string.
    • Query Parameters:
      • car_str (str): The car description for which to retrieve the embeddings.
      • n_results (int): The number of nearest embeddings to return (default: 5).
    • Returns: - [{current_bid_formatted: string, excerpt: string,thumbnail_url: string, title: string}]: A list of the nearest car vector matches for the given car string.

Usage

  • Use the API to retrieve, update, embedding records.
  • Interact with the ChromaDB to query embedding vectors based on textual inputs.
  • Generate embeddings from text data using the SentenceTransformer model.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

License:MIT License


Languages

Language:Python 100.0%