Struct txtai::embeddings::Embeddings[][src]

pub struct Embeddings { /* fields omitted */ }

Embeddings definition

Implementations

impl Embeddings[src]

Embeddings implementation

pub fn new(url: &str) -> Embeddings[src]

Creates an Embeddings instance.

Arguments

  • url - base url of txtai API

pub async fn query(&self, query: &str, limit: i32) -> APIResponse[src]

Runs an Embeddings search. Returns Response. This method allows callers to customize the serialization of the response.

Arguments

  • query - query text
  • limit - maximum results

pub async fn search(&self, query: &str, limit: i32) -> SearchResults[src]

Finds documents in the embeddings model most similar to the input query. Returns a list of {id: value, score: value} sorted by highest score, where id is the document id in the embeddings model.

Arguments

  • query - query text
  • limit - maximum results

pub async fn batchsearch(&self, queries: &str, limit: i32) -> SearchResultsBatch[src]

Finds documents in the embeddings model most similar to the input queries. Returns a list of {id: value, score: value} sorted by highest score per query, where id is the document id in the embeddings model.

Arguments

  • queries - queries text
  • limit - maximum results

pub async fn add<T: Serialize>(&self, documents: &Vec<T>) -> APIResponse[src]

Adds a batch of documents for indexing.

Arguments

  • documents - list of {id: value, text: value}

pub async fn index(&self) -> APIResponse[src]

Builds an embeddings index for previously batched documents. No further documents can be added after this call.

pub async fn similarity(&self, query: &str, texts: &Vec<&str>) -> IndexResults[src]

Computes the similarity between query and list of text. Returns a list of {id: value, score: value} sorted by highest score, where id is the index in texts.

Arguments

  • query - query text
  • texts - list of text

pub async fn batchsimilarity(
    &self,
    queries: &Vec<&str>,
    texts: &Vec<&str>
) -> IndexResultsBatch
[src]

Computes the similarity between list of queries and list of text. Returns a list of {id: value, score: value} sorted by highest score per query, where id is the index in texts.

Arguments

  • queries - queries text
  • texts - list of text

pub async fn transform(&self, text: &str) -> Embedding[src]

Transforms text into an embeddings array.

Arguments

  • text - input text

pub async fn batchtransform(&self, texts: &str) -> EmbeddingBatch[src]

Transforms list of text into embeddings arrays.

Arguments

  • texts - lists of text

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.