pub enum EmbeddingTask {
NL2Code,
Code2Code,
Code2NL,
Code2Completion,
QA,
}Expand description
Embedding task types for Jina Code Embeddings 1.5B.
Each task type has separate instruction prefixes for queries and passages, enabling asymmetric retrieval (queries and documents are embedded differently).
§Example
use aurora_semantic::{JinaCodeEmbedder, EmbeddingTask};
// For indexing code (use passage prefix)
let code_embedder = JinaCodeEmbedder::from_directory("./models/jina-code-1.5b")?
.with_task(EmbeddingTask::NL2Code);
let code_embedding = code_embedder.embed_passage("fn parse_json(s: &str) -> Value { }")?;
// For search queries (use query prefix)
let query_embedding = code_embedder.embed_query("function to parse JSON")?;Variants§
NL2Code
Natural language to code retrieval (default). Use for: finding code snippets from natural language queries.
Code2Code
Code to code retrieval. Use for: finding similar code snippets.
Code2NL
Code to natural language. Use for: finding comments/documentation for code.
Code2Completion
Code completion retrieval. Use for: finding code completions.
QA
Technical question answering. Use for: finding answers to programming questions.
Implementations§
Source§impl EmbeddingTask
impl EmbeddingTask
Sourcepub fn query_prefix(&self) -> &'static str
pub fn query_prefix(&self) -> &'static str
Get the instruction prefix for QUERY embeddings.
Use this when embedding search queries.
Sourcepub fn passage_prefix(&self) -> &'static str
pub fn passage_prefix(&self) -> &'static str
Get the instruction prefix for PASSAGE/DOCUMENT embeddings.
Use this when embedding code or documents to be indexed.
Sourcepub fn instruction_prefix(&self) -> &'static str
pub fn instruction_prefix(&self) -> &'static str
Get the default instruction prefix (alias for query_prefix).
For backward compatibility.
Trait Implementations§
Source§impl Clone for EmbeddingTask
impl Clone for EmbeddingTask
Source§fn clone(&self) -> EmbeddingTask
fn clone(&self) -> EmbeddingTask
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EmbeddingTask
impl Debug for EmbeddingTask
Source§impl Default for EmbeddingTask
impl Default for EmbeddingTask
Source§fn default() -> EmbeddingTask
fn default() -> EmbeddingTask
Source§impl<'de> Deserialize<'de> for EmbeddingTask
impl<'de> Deserialize<'de> for EmbeddingTask
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for EmbeddingTask
impl PartialEq for EmbeddingTask
Source§impl Serialize for EmbeddingTask
impl Serialize for EmbeddingTask
impl Copy for EmbeddingTask
impl Eq for EmbeddingTask
impl StructuralPartialEq for EmbeddingTask
Auto Trait Implementations§
impl Freeze for EmbeddingTask
impl RefUnwindSafe for EmbeddingTask
impl Send for EmbeddingTask
impl Sync for EmbeddingTask
impl Unpin for EmbeddingTask
impl UnwindSafe for EmbeddingTask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more