自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

LanceDB:為 AI 應(yīng)用打造的高效嵌入式向量數(shù)據(jù)庫(kù)

發(fā)布于 2024-12-24 11:41
瀏覽
0收藏

當(dāng)前,向量數(shù)據(jù)庫(kù)已經(jīng)成了一個(gè)紅海市場(chǎng),新興的還是傳統(tǒng)數(shù)據(jù)庫(kù)廠商都在做這方面的工作。然而,在嵌入式,端上的向量數(shù)據(jù)庫(kù)比較少,chromaDB算是其中一個(gè),但它不算是一個(gè)純?cè)⑸疃葍?yōu)化的的嵌入式向量數(shù)據(jù)庫(kù),仍采用parquet格式(讀一行數(shù)據(jù)需要讀取整個(gè)塊解壓,比較慢,另外副本占用空間),功能也比較少,那有沒(méi)有更好的選擇呢?很多人自然想到關(guān)系型嵌入式數(shù)據(jù)庫(kù)王者——Sqlite,奈何它的向量版本 sqlite-vec還處于開(kāi)發(fā)中,那有沒(méi)有文檔性能還好的替代品呢?LanceDB是一個(gè)選擇。

LanceDB 是一個(gè)專(zhuān)為構(gòu)建 AI 應(yīng)用而設(shè)計(jì)的開(kāi)源向量數(shù)據(jù)庫(kù)。它采用嵌入式架構(gòu),無(wú)需部署獨(dú)立服務(wù)器,可以輕松集成到各種應(yīng)用場(chǎng)景中。

LanceDB:為 AI 應(yīng)用打造的高效嵌入式向量數(shù)據(jù)庫(kù)-AI.x社區(qū)

核心功能和優(yōu)勢(shì)在于:

  1. 嵌入式架構(gòu)。與需要部署服務(wù)器的 Qdrant 等產(chǎn)品不同,LanceDB 采用嵌入式設(shè)計(jì),作為應(yīng)用的一部分運(yùn)行,易于集成且無(wú)需額外的基礎(chǔ)設(shè)施管理。
  2. 專(zhuān)為AI設(shè)計(jì)的Lance 數(shù)據(jù)格式(最大亮點(diǎn))。LanceDB 使用專(zhuān)門(mén)優(yōu)化的 Lance 列式存儲(chǔ)格式,相比傳統(tǒng)的 Parquet 格式具有更快的掃描速度。它支持?jǐn)?shù)據(jù)分片,只加載必要的數(shù)據(jù)片段,大大減少 IO 開(kāi)銷(xiāo)。同時(shí)具有機(jī)器學(xué)習(xí)所需的自動(dòng)數(shù)據(jù)版本管理能力,不同的版本會(huì)關(guān)聯(lián)該版本相關(guān)文件、模式及 blob 的元數(shù)據(jù),更新數(shù)據(jù)時(shí)無(wú)需完整重寫(xiě)(Zero-copy)。

LanceDB:為 AI 應(yīng)用打造的高效嵌入式向量數(shù)據(jù)庫(kù)-AI.x社區(qū)

相較于其他的常見(jiàn)格式對(duì)比,在機(jī)器學(xué)習(xí)場(chǎng)景場(chǎng)景中優(yōu)勢(shì)明顯:

LanceDB:為 AI 應(yīng)用打造的高效嵌入式向量數(shù)據(jù)庫(kù)-AI.x社區(qū)

數(shù)據(jù)cap理論


Lance

Parquet & ORC

JSON & XML

TFRecord

Database

Warehouse

Analytics

Fast

Fast

Slow

Slow

Decent

Fast

Feature Engineering

Fast

Fast

Decent

Slow

Decent

Good

Training

Fast

Decent

Slow

Fast

N/A

N/A

Exploration

Fast

Slow

Fast

Slow

Fast

Decent

Infra Support

Rich

Rich

Decent

Limited

Rich

Rich

  1. 高性能向量搜索?;?Rust 語(yǔ)言開(kāi)發(fā),具有優(yōu)秀的性能表現(xiàn)。根據(jù)官方基準(zhǔn)測(cè)試,在同等硬件條件下,對(duì)于 128 維向量的 10 億規(guī)模數(shù)據(jù)集,查詢(xún)延遲可以控制在 100ms 以?xún)?nèi)。并且支持GPU加速。
  2. 豐富的生態(tài)集成。LanceDB 原生支持 Python 和JavaScript/TypeScript,并與 LangChain 、LlamaIndex 等主流 AI 框架無(wú)縫集成。同時(shí)也支持 Apache Arrow 、Pandas 、Polars 、DuckDB 等數(shù)據(jù)處理工具。
  3. 多模態(tài)數(shù)據(jù)支持。除了向量數(shù)據(jù),LanceDB 還能高效存儲(chǔ)和檢索文本、圖像、音頻等非結(jié)構(gòu)化數(shù)據(jù),無(wú)需額外的存儲(chǔ)解決方案。

使用 LanceDB 非常簡(jiǎn)單,下面是使用示例:

  • Python版本:

import lancedb

# 連接數(shù)據(jù)庫(kù)
db = lancedb.connect("data/sample-lancedb")

# 創(chuàng)建表并插入數(shù)據(jù)
table = db.create_table("my_table",
    data=[{"vector": [3.1, 4.1], "item": "foo", "price": 10.0},
          {"vector": [5.9, 26.5], "item": "bar", "price": 20.0}])

# 執(zhí)行向量搜索
result = table.search([100, 100]).limit(2).to_pandas()
  • js版本,搭配transformers使用。

async function example() {

    const lancedb = require('vectordb')

    // Import transformers and the all-MiniLM-L6-v2 model (https://huggingface.co/Xenova/all-MiniLM-L6-v2)
    const { pipeline } = await import('@xenova/transformers')
    const pipe = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');


    // Create embedding function from pipeline which returns a list of vectors from batch
    // sourceColumn is the name of the column in the data to be embedded
    //
    // Output of pipe is a Tensor { data: Float32Array(384) }, so filter for the vector
    const embed_fun = {}
    embed_fun.sourceColumn = 'text'
    embed_fun.embed = async function (batch) {
        let result = []
        for (let text of batch) {
            const res = await pipe(text, { pooling: 'mean', normalize: true })
            result.push(Array.from(res['data']))
        }
        return (result)
    }

    // Link a folder and create a table with data
    const db = await lancedb.connect('data/sample-lancedb')

    const data = [
        { id: 1, text: 'Cherry', type: 'fruit' },
        { id: 2, text: 'Carrot', type: 'vegetable' },
        { id: 3, text: 'Potato', type: 'vegetable' },
        { id: 4, text: 'Apple', type: 'fruit' },
        { id: 5, text: 'Banana', type: 'fruit' }
    ]

    const table = await db.createTable('food_table', data, embed_fun)


    // Query the table
    const results = await table
        .search("a sweet fruit to eat")
        .metricType("cosine")
        .limit(2)
        .execute()
    console.log(results.map(r => r.text))

}

example().then(_ => { console.log("Done!") })

更多參考資源:??https://github.com/lancedb/vectordb-recipes??

相比需要部署服務(wù)器的向量數(shù)據(jù)庫(kù),LanceDB 的嵌入式架構(gòu)特別適合:

  • 需要在本地運(yùn)行的桌面應(yīng)用
  • 資源受限的邊緣計(jì)算環(huán)境
  • 對(duì)數(shù)據(jù)隱私有嚴(yán)格要求的場(chǎng)景
  • 快速原型開(kāi)發(fā)和測(cè)試

雖然在處理海量數(shù)據(jù)時(shí),LanceDB 展現(xiàn)出了顯著的性能優(yōu)勢(shì),但對(duì)于大多數(shù)中小規(guī)模的 AI 應(yīng)用來(lái)說(shuō),開(kāi)發(fā)效率和易用性可能是更重要的考慮因素。LanceDB 簡(jiǎn)單直觀的 API 設(shè)計(jì)和完善的生態(tài)支持,使其成為構(gòu)建各類(lèi) AI 應(yīng)用的理想選擇。

小結(jié)

事實(shí)上,當(dāng)前很多的應(yīng)用都選擇lancedb作為其實(shí)現(xiàn)方案,比如微軟的GraphRAG,Character AI , MidJourney等,它們也獲得了YC 800 萬(wàn)美元的種子輪融資。2025年,我們將迎來(lái)多模態(tài)LLM應(yīng)用的爆發(fā),這也將會(huì)帶來(lái)向量數(shù)據(jù)庫(kù)的新一輪的熱潮,作為嵌入式向量數(shù)據(jù)庫(kù)的最佳代表,無(wú)論是用于構(gòu)建原型還是部署生產(chǎn)環(huán)境,都是一個(gè)值得考慮的選擇,甚至可能是不二選擇。

參考:

??https://blog.lancedb.com/new-funding-and-a-new-foundation-for-multimodal-ai-data/??

??https://lancedb.github.io/??

??https://github.com/lancedb/lancedb??

本文轉(zhuǎn)載自 ??AI工程化??,作者: ully

收藏
回復(fù)
舉報(bào)
回復(fù)
相關(guān)推薦