Coder Social home page Coder Social logo

kkxiaotikk / awadb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from awa-ai/awadb

0.0 1.0 0.0 3.67 MB

AI Native database for embedding vectors

License: Apache License 2.0

Shell 0.11% C++ 74.79% Python 20.73% C 0.33% Makefile 0.01% CMake 4.04%

awadb's Introduction

AwaDB - the AI Native database for embedding vectors.
Store and search embedding vectors for LLM Applications!

# Install awadb
pip3 install awadb -r requirements.txt 

Now support Linux(python>=3.6), MacOSX(x86-64 architecture, m1 or m2 arm64 architecture python>=3.8)

The core API is only 4 steps:

import awadb
# 1. Initialize awadb client!
awadb_client = awadb.Client()

# 2. Create table!
awadb_client.Create("testdb")

# 3. Add docs to the table. Can also update and delete the doc!
awadb_client.Add([{'name':'jim'}, {'age':39}, {'desc':'hello'}, {'vec':[1, 3.5, 3]}])
awadb_client.Add([{'name':'vincent'}, {'age':28}, {'desc':'world'}, {'vec':[1, 3.4, 2]}])
awadb_client.Add([{'name':'david'}, {'age':45}, {'desc':'hi'},  {'vec':[1, 2.4, 4]}])
awadb_client.Add([{'name':'tom'}, {'age':25}, {'desc':'dolly'}, {'vec':[1.3, 2.9, 8.9]}])

# 4. Search by specified vector query and the most TopK similar results
results = awadb_client.Search([3.0, 3.1, 4.2], 3)

# Output the results
print(results)

You can also directly use awadb to do the text semantic retrieval
Here the text is embedded by SentenceTransformer which is supported by Hugging Face

import awadb
# 1. Initialize awadb client!
awadb_client = awadb.Client()

# 2. Create table
awadb_client.Create("test_llm1") 

# 3. Add sentences, the sentence is embedded with SentenceTransformer by default
#    You can also embed the sentences all by yourself with OpenAI or other LLMs
awadb_client.Add([{'embedding_text':'The man is happy'}, {'source' : 'pic1'}])
awadb_client.Add([{'embedding_text':'The man is very happy'}, {'source' : 'pic2'}])
awadb_client.Add([{'embedding_text':'The cat is happy'}, {'source' : 'pic3'}])
awadb_client.Add([{'embedding_text':'The man is eating'}, {'source':'pic4'}])

# 4. Search the most Top3 sentences by the specified query
query = "The man is happy"
results = awadb_client.Search(query, 3)

# Output the results
print(results)

What are the Embeddings?

Any unstructured data(image/text/audio/video) can be transferred to vectors which are generally understanded by computers through AI(LLMs or other deep neural networks).

For example, "The man is happy"-this sentence can be transferred to a 384-dimension vector(a list of numbers [0.23, 1.98, ....]) by SentenceTransformer language model. This process is called embedding.

More detailed information about embeddings can be read from OpenAI

Awadb uses Sentence Transformers to embed the sentence by default, while you can also use OpenAI or other LLMs to do the embeddings according to your needs.

Combined with LLMs(OpenAI, Llama, Vicuna, Alpaca, ChatGLM, Dolly)

Examples of combining LLaMa or quantized Alpaca with llama.cpp to do local knowledge database please see here
Examples of combining ChatGLM to do local knowledge database please see here

Get involved

License

Apache 2.0

Docs

docs

Community

Join the AwaDB community to share any problem, suggestion, or discussion with us:

awadb's People

Contributors

awa-ai avatar jiazhai avatar ljeagle avatar wangning19940904 avatar wukathy21 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.