| Title: | Native 'BebeLM', 'EmbeddingGemma', and 'ColBERT' CPU Backends for R |
|---|---|
| Description: | Provides focused R interfaces to the pure-Rust 'BebeLM' CPU inference library <https://github.com/maximecb/bebelm> and a native pure-Rust implementation of the retrieval-trained 'EmbeddingGemma' encoder <https://ai.google.dev/gemma/docs/embeddinggemma>, and a native profile for LiquidAI's retrieval-trained LFM2.5-'ColBERT' GGUF encoder. The package exposes GGUF model loading, tokenizer access, semantic text embeddings, late-interaction token vectors and MaxSim scoring, streaming generation events, persistent conversation agents, 'BebeLM' tool-call parsing, R tool dispatch, and Rust-thread async generation jobs. Loaded agents share model weights in process through Rust reference-counted handles, and GGUF files are mapped read-only so repeated loads of the same file can share physical pages through the operating-system page cache. Native libraries are built as runtime-selected CPU backends so portable R binaries can use scalar code by default and optimized SIMD backends when available. |
| Authors: | Sounkou Mahamane Toure [aut, cre], Maxime Chevalier-Boisvert [cph] (BebeLM upstream), Hiroaki Yutani [cph] (savvy R/Rust interface), llama.cpp contributors [ctb, cph] (MIT-licensed tokenizer and EmbeddingGemma reference semantics) |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.3.6-0.1.0 |
| Built: | 2026-07-21 19:32:02 UTC |
| Source: | https://github.com/RGenomicsETL/Rbebelm |
A BebelAgent owns an independent token transcript and decode cache while
sharing the loaded model weights through Rust Arc<Model>.
bebel_agent( model, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )bebel_agent( model, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
model |
A |
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
A BebelAgent object.
Configure a BebeLM agent
bebel_agent_configure( agent, greedy = NULL, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )bebel_agent_configure( agent, greedy = NULL, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
agent |
A |
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
Updated agent info.
Generate a raw continuation from a BebeLM agent transcript
bebel_agent_generate(agent, on_event = NULL, check_interrupt = TRUE)bebel_agent_generate(agent, on_event = NULL, check_interrupt = TRUE)
agent |
A |
on_event |
Event handler function, named list of event-specific handlers, or
|
check_interrupt |
Check for R interrupts during synchronous agent generation. |
A classed generation result.
The job runs on a cloned agent snapshot. The original agent's transcript and decode cache are not mutated, while the model weights are shared.
bebel_agent_generate_async(agent)bebel_agent_generate_async(agent)
agent |
A |
A BebelAsyncJob.
Inspect a BebeLM agent
bebel_agent_info(agent)bebel_agent_info(agent)
agent |
A |
Named list of state and configuration.
This is an Agent-first orchestration loop. It observes tool_call_end events,
parses tool calls, invokes matching R tools with private context, appends
tool results to the agent transcript, and continues generation.
bebel_agent_run( agent, tools = list(), context = new.env(parent = emptyenv()), hooks = list(), parse_tool_call = bebel_parse_tool_calls, max_steps = 4, on_event = NULL, check_interrupt = TRUE )bebel_agent_run( agent, tools = list(), context = new.env(parent = emptyenv()), hooks = list(), parse_tool_call = bebel_parse_tool_calls, max_steps = 4, on_event = NULL, check_interrupt = TRUE )
agent |
A |
tools |
A list of |
context |
Private run context passed to tools and hooks but not appended to the model transcript. |
hooks |
Optional named list of hooks: |
parse_tool_call |
Function converting tool-call content to either one |
max_steps |
Maximum assistant/tool iterations. |
on_event |
Optional event handler function or named handler list for model events. |
check_interrupt |
Check for Ctrl-C during generation. |
A bebelAgentRun list with turns, tool calls, and final agent info.
Append raw text to a BebeLM agent transcript
bebel_append(agent, text)bebel_append(agent, text)
agent |
A |
text |
Raw text to append. |
Invisibly returns agent.
Delegates ChatML system-turn rendering to upstream BebeLM. When tools are
supplied, their schemas are rendered in upstream's List of tools: [...]
system-block preamble before message.
bebel_append_system(agent, message, tools = NULL)bebel_append_system(agent, message, tools = NULL)
agent |
A |
message |
System instruction text. |
tools |
Optional list of |
Invisibly returns agent.
Append token ids to a BebeLM agent transcript
bebel_append_tokens(agent, ids)bebel_append_tokens(agent, ids)
agent |
A |
ids |
Integer token ids. |
Invisibly returns agent.
Append a ChatML tool result turn to a BebeLM agent transcript
bebel_append_tool_result(agent, content)bebel_append_tool_result(agent, content)
agent |
A |
content |
Tool result content to append. |
Invisibly returns agent.
Append a ChatML user turn to a BebeLM agent transcript
bebel_append_user(agent, message)bebel_append_user(agent, message)
agent |
A |
message |
User message. |
Invisibly returns agent.
Generate and close an assistant ChatML turn from a BebeLM agent
bebel_assistant_turn(agent, on_event = NULL, check_interrupt = TRUE)bebel_assistant_turn(agent, on_event = NULL, check_interrupt = TRUE)
agent |
A |
on_event |
Event handler function, named list of event-specific handlers, or
|
check_interrupt |
Check for R interrupts during synchronous agent generation. |
A classed generation result.
Start a background assistant-turn job
bebel_assistant_turn_async(agent)bebel_assistant_turn_async(agent)
agent |
A |
A BebelAsyncJob.
This low-level variant mirrors upstream BebeLM's tool driver stop semantics:
generation stops with stop == "tool_call" after <|tool_call_end|> so the
caller can execute the requested tool and append one tool-result turn.
bebel_assistant_turn_tool_stop(agent, on_event = NULL, check_interrupt = TRUE)bebel_assistant_turn_tool_stop(agent, on_event = NULL, check_interrupt = TRUE)
agent |
A |
on_event |
Event handler function, named list of event-specific handlers, or
|
check_interrupt |
Check for R interrupts during synchronous agent generation. |
A bebelAssistantTurnResult list.
Start a background assistant-turn job that stops on tool-call close
bebel_assistant_turn_tool_stop_async(agent)bebel_assistant_turn_tool_stop_async(agent)
agent |
A |
A BebelAsyncJob.
Requests cancellation from Rust. A cancelled job stops at the next generation checkpoint and raises an error when collected.
bebel_async_cancel(job)bebel_async_cancel(job)
job |
A |
TRUE when this call set the cancellation flag for the first time.
Collect a BebeLM async job result
bebel_async_collect(job, wait = TRUE)bebel_async_collect(job, wait = TRUE)
job |
A |
wait |
If |
A classed generation result, or NULL.
Drain queued BebeLM async job events
bebel_async_events(job, max = NULL)bebel_async_events(job, max = NULL)
job |
A |
max |
Optional maximum number of queued events to drain. |
A list of generation event lists.
Poll a BebeLM async job
bebel_async_poll(job)bebel_async_poll(job)
job |
A |
"ready" or "pending".
Drains queued stream events on the R thread while polling the job, then collects the finished result.
bebel_async_wait( job, on_event = NULL, poll_interval = 0.005, cancel_on_interrupt = TRUE )bebel_async_wait( job, on_event = NULL, poll_interval = 0.005, cancel_on_interrupt = TRUE )
job |
A |
on_event |
Event handler function, named list of event-specific handlers,
or |
poll_interval |
Seconds to sleep between polls while the job is pending. |
cancel_on_interrupt |
Whether an interrupted wait should request Rust-side job cancellation. |
A classed generation result.
Launches deterministic generation jobs in bounded async batches against one loaded model and records per-job timing, token counts, event counts, and aggregate throughput.
bebel_benchmark_generation( model, prompts, concurrency = min(length(prompts), 2L), repeats = 1L, greedy = TRUE, max_gen = 64L, max_context = NULL, max_think = 0L, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.001 )bebel_benchmark_generation( model, prompts, concurrency = min(length(prompts), 2L), repeats = 1L, greedy = TRUE, max_gen = 64L, max_context = NULL, max_think = 0L, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.001 )
model |
A |
prompts |
Character vector of prompts. |
concurrency |
Maximum number of async jobs in flight. |
repeats |
Number of times to repeat the prompt set. |
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
poll_interval |
Seconds to sleep between async-job polls. |
A bebelGenerationBenchmark list.
Generate a single ChatML assistant reply
bebel_chat( model, message, greedy = FALSE, on_event = NULL, check_interrupt = TRUE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.005 )bebel_chat( model, message, greedy = FALSE, on_event = NULL, check_interrupt = TRUE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.005 )
model |
A |
message |
User message. |
greedy |
Use deterministic greedy decoding. |
on_event |
Event handler function, named list of event-specific handlers, or
|
check_interrupt |
Cancel the underlying async job when the R wait is interrupted. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
poll_interval |
Seconds to sleep between async-job polls. |
A classed generation result.
Start a background ChatML assistant reply job
bebel_chat_async( model, message, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )bebel_chat_async( model, message, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
model |
A |
message |
User message. |
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
A BebelAsyncJob.
Clears the conversation state while keeping the loaded model weights and the agent's generation configuration.
bebel_clear(agent)bebel_clear(agent)
agent |
A |
Updated agent info.
Decode BebeLM token ids
bebel_detokenize(model, ids)bebel_detokenize(model, ids)
model |
A |
ids |
Integer token ids. |
Decoded text.
bebel_event_handler() creates a single on_event handler function from handlers for
individual event types. Current event types are returned by
bebel_event_types().
bebel_event_handler( start = NULL, thinking_start = NULL, thinking_delta = NULL, thinking_end = NULL, text_start = NULL, text_delta = NULL, text_end = NULL, tool_list_start = NULL, tool_list_delta = NULL, tool_list_end = NULL, tool_call_start = NULL, tool_call_delta = NULL, tool_call_end = NULL, done = NULL, default = NULL )bebel_event_handler( start = NULL, thinking_start = NULL, thinking_delta = NULL, thinking_end = NULL, text_start = NULL, text_delta = NULL, text_end = NULL, tool_list_start = NULL, tool_list_delta = NULL, tool_list_end = NULL, tool_call_start = NULL, tool_call_delta = NULL, tool_call_end = NULL, done = NULL, default = NULL )
start, thinking_start, thinking_delta, thinking_end, text_start, text_delta, text_end
|
Optional functions called for the corresponding stream event. |
tool_list_start, tool_list_delta, tool_list_end
|
Optional handlers for BebeLM tool-list delimiter blocks. |
tool_call_start, tool_call_delta, tool_call_end
|
Optional handlers for BebeLM tool-call delimiter blocks. |
done |
Function called for the final done event, or |
default |
Function called for events without a type-specific handler, or |
A function accepting one generation event list.
Return BebeLM stream event types.
bebel_event_types()bebel_event_types()
Generate a raw continuation from a prompt
bebel_generate( model, prompt, greedy = FALSE, on_event = NULL, check_interrupt = TRUE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.005 )bebel_generate( model, prompt, greedy = FALSE, on_event = NULL, check_interrupt = TRUE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL, poll_interval = 0.005 )
model |
A |
prompt |
Prompt text. |
greedy |
Use deterministic greedy decoding. |
on_event |
Event handler function, named list of event-specific handlers, or
|
check_interrupt |
Cancel the underlying async job when the R wait is interrupted. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
poll_interval |
Seconds to sleep between async-job polls. |
A classed list with generated text, token ids, stop reason, and timing statistics.
Async jobs run BebeLM generation on Rust worker threads and reuse the loaded
model weights. They are polled with bebel_async_poll() and collected with
bebel_async_collect().
bebel_generate_async( model, prompt, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )bebel_generate_async( model, prompt, greedy = FALSE, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
model |
A |
prompt |
Prompt text. |
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
A BebelAsyncJob.
Return a BebeLM agent token transcript
bebel_history(agent)bebel_history(agent)
agent |
A |
Integer token ids.
Load a BebeLM GGUF model
bebel_model_load(path, num_threads = NULL)bebel_model_load(path, num_threads = NULL)
path |
Path to the GGUF weights file. |
num_threads |
Optional Rayon global thread-pool size. This can only be set once per R process. |
A BebelModel object.
Parse a single BebeLM tool call block
bebel_parse_tool_call(content)bebel_parse_tool_call(content)
content |
Accumulated content between BebeLM tool-call delimiters. |
A list with name, arguments, and raw.
Delegates Pythonic BebeLM tool-call parsing ([name(arg='value')]) to
upstream BebeLM. JSON call objects and legacy name({...}) calls are parsed
with imported package yyjsonr.
bebel_parse_tool_calls(content)bebel_parse_tool_calls(content)
content |
Accumulated content between BebeLM tool-call delimiters. |
A list of calls, each with name, arguments, and raw.
Return BebeLM tokenizer special token ids.
bebel_token_ids()bebel_token_ids()
Tokenize text with a BebeLM model tokenizer
bebel_tokenize(model, text, add_bos = TRUE)bebel_tokenize(model, text, add_bos = TRUE)
model |
A |
text |
Text to encode. |
add_bos |
Whether to prepend the BOS token. |
Integer token ids.
Define a BebeLM R tool
bebel_tool(name, fun, description = NULL, schema = NULL)bebel_tool(name, fun, description = NULL, schema = NULL)
name |
Tool name exposed to the tool dispatcher. |
fun |
Function to run. It is called as |
description |
Optional human-readable description. |
schema |
Optional JSON-schema-like list or JSON string. |
A BebelToolSpec object.
Converts an R bebel_tool() declaration into BebeLM's JSON tool schema string
for the system List of tools: [...] preamble.
bebel_tool_schema_json(tool)bebel_tool_schema_json(tool)
tool |
A |
A character scalar containing the rendered tool schema.
Decode a BebeLM agent transcript
bebel_transcript(agent)bebel_transcript(agent)
agent |
A |
Transcript text.
Persistent BebeLM conversation agent with transcript and decode caches.
BebelAgentBebelAgent
Agent configuration update
BebelAgentConfigureOptions( greedy = NULL, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )BebelAgentConfigureOptions( greedy = NULL, max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
greedy |
Optional logical decoding-mode update. |
max_gen, max_context, max_think
|
Optional generation-limit updates. |
temperature, top_k, repeat_penalty
|
Optional sampling-setting updates. |
Agent construction options
BebelAgentOptions( greedy = logical(0), max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )BebelAgentOptions( greedy = logical(0), max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
greedy |
Use deterministic greedy decoding. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
BebeLM agent reference
BebelAgentRef(value = list())BebelAgentRef(value = list())
value |
A one-element list containing a |
Agent run options
BebelAgentRunOptions(max_steps = integer(0), check_interrupt = logical(0))BebelAgentRunOptions(max_steps = integer(0), check_interrupt = logical(0))
max_steps |
Maximum assistant/tool iterations. |
check_interrupt |
Check for R user interrupts during synchronous generation. |
Async event drain options
BebelAsyncEventDrainOptions(max = NULL)BebelAsyncEventDrainOptions(max = NULL)
max |
Optional non-negative whole-number event limit. |
Background BebeLM generation job.
BebelAsyncJobBebelAsyncJob
BebeLM async job reference
BebelAsyncJobRef(value = list())BebelAsyncJobRef(value = list())
value |
A one-element list containing a |
Async wait options
BebelAsyncWaitOptions( poll_interval = integer(0), cancel_on_interrupt = logical(0) )BebelAsyncWaitOptions( poll_interval = integer(0), cancel_on_interrupt = logical(0) )
poll_interval |
Seconds to sleep between polls while a job is pending. |
cancel_on_interrupt |
Whether an interrupted wait should request Rust-side job cancellation. |
Generation benchmark options
BebelGenerationBenchmarkOptions( prompts = character(0), concurrency = integer(0), repeats = integer(0), poll_interval = integer(0) )BebelGenerationBenchmarkOptions( prompts = character(0), concurrency = integer(0), repeats = integer(0), poll_interval = integer(0) )
prompts |
Character vector of prompts. |
concurrency |
Maximum number of async jobs in flight. |
repeats |
Number of times to repeat the prompt set. |
poll_interval |
Seconds to sleep between monitor polls. |
Generation options
BebelGenerationOptions( greedy = logical(0), check_interrupt = logical(0), max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )BebelGenerationOptions( greedy = logical(0), check_interrupt = logical(0), max_gen = NULL, max_context = NULL, max_think = NULL, temperature = NULL, top_k = NULL, repeat_penalty = NULL )
greedy |
Use deterministic greedy decoding. |
check_interrupt |
Check for R user interrupts during synchronous generation. |
max_gen, max_context, max_think
|
Optional generation limits. |
temperature, top_k, repeat_penalty
|
Optional sampling settings. |
Loaded BebeLM GGUF generation model.
BebelModelBebelModel
Model loading options
BebelModelLoadOptions(path = character(0), num_threads = NULL)BebelModelLoadOptions(path = character(0), num_threads = NULL)
path |
Path to a GGUF weights file. |
num_threads |
Optional positive whole-number Rayon thread count. |
BebeLM model reference
BebelModelRef(value = list())BebelModelRef(value = list())
value |
A one-element list containing a |
Scalar non-empty text
BebelScalarText(value = character(0))BebelScalarText(value = character(0))
value |
A non-empty character scalar. |
Tokenizer options
BebelTokenizeOptions(add_bos = logical(0))BebelTokenizeOptions(add_bos = logical(0))
add_bos |
Whether to prepend the model's beginning-of-sequence token. |
BebeLM tool reference
BebelToolRef(value = list())BebelToolRef(value = list())
value |
A one-element list containing a |
R tool exposed to BebeLM
BebelToolSpec( name = character(0), fun = NULL, description = NULL, schema = NULL )BebelToolSpec( name = character(0), fun = NULL, description = NULL, schema = NULL )
name |
Tool name exposed to the model and dispatcher. |
fun |
R function called for matching tool calls. |
description |
Optional tool description. |
schema |
Optional JSON-schema-like list or JSON string. |
Return model-input ids aligned to ColBERT token vectors
colbert_embedding_ids(embeddings)colbert_embedding_ids(embeddings)
embeddings |
A |
Integer token ids, one per vector row.
Materialize ColBERT token vectors
colbert_embedding_vectors(embeddings)colbert_embedding_vectors(embeddings)
embeddings |
A |
An n_tokens × 128 numeric matrix whose rows have unit L2 norm.
Inspect ColBERT token vectors
colbert_embeddings_info(embeddings)colbert_embeddings_info(embeddings)
embeddings |
A |
A named list containing role, token count, and dimensions.
Applies the profile's required [D] prefix, encodes up to 512 positions,
projects them to L2-normalized token vectors, then removes only the
profile's published punctuation skip-list from the scoring vectors.
colbert_encode_document(model, text)colbert_encode_document(model, text)
model |
A |
text |
A non-empty document string. |
A document ColbertEmbeddings object.
Applies the profile's required [Q] prefix, encodes exactly 32 query
positions (including learned PAD expansion positions), projects them to
L2-normalized 128-dimensional token vectors, and returns a
ColbertEmbeddings handle.
colbert_encode_query(model, text)colbert_encode_query(model, text)
model |
A |
text |
A non-empty query string. |
A query ColbertEmbeddings object.
Computes sum_i max_j(q_i dot d_j), where query and document token vectors
were generated by colbert_encode_query() and colbert_encode_document().
colbert_maxsim(query, document)colbert_maxsim(query, document)
query |
Query |
document |
Document |
A numeric MaxSim relevance score.
Inspect a ColBERT model
colbert_model_info(model)colbert_model_info(model)
model |
A |
A named list describing its token-vector and MaxSim contract.
Loads LiquidAI's retrieval-trained late-interaction encoder. This profile is
distinct from BebelModel: it uses bidirectional attention, learned
token-level projections, separate query/document formatting, and ColBERT
MaxSim rather than pooling states from a generation model.
colbert_model_load(path, num_threads = NULL)colbert_model_load(path, num_threads = NULL)
path |
Path to an |
num_threads |
Optional Rayon global thread-pool size. This can only be set once per R process. |
A ColbertModel object.
This convenience helper performs exact in-memory scoring. It is suitable for a candidate set; production-scale retrieval needs an external late- interaction index built with the same profile and preprocessing contract.
colbert_rank(model, query, documents)colbert_rank(model, query, documents)
model |
A |
query |
A non-empty query string. |
documents |
A non-empty character vector of candidate documents. |
A decreasing named numeric vector of MaxSim scores with class
colbertRanking.
One query or document's L2-normalized ColBERT token vectors.
ColbertEmbeddingsColbertEmbeddings
ColBERT token-vector reference
ColbertEmbeddingsRef(value = list())ColbertEmbeddingsRef(value = list())
value |
A one-element list containing |
Loaded LFM2.5-ColBERT GGUF model.
ColbertModelColbertModel
ColBERT loading options
ColbertModelLoadOptions(path = character(0), num_threads = NULL)ColbertModelLoadOptions(path = character(0), num_threads = NULL)
path |
Path to an LFM2.5-ColBERT GGUF weights file. |
num_threads |
Optional positive whole-number Rayon thread count. |
ColBERT model reference
ColbertModelRef(value = list())ColbertModelRef(value = list())
value |
A one-element list containing a |
Runs the retrieval-trained bidirectional Gemma encoder, attention-mask mean pooling, and both learned dense projection layers. The requested task is deliberately mandatory: EmbeddingGemma was trained with different prompt contracts for queries, documents, semantic similarity, and other tasks.
embeddinggemma_embed( model, text, task, title = NULL, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )embeddinggemma_embed( model, text, task, title = NULL, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )
model |
An |
text |
Character vector to embed. |
task |
One of |
title |
Optional document-title scalar or vector. It is valid only for
|
dimensions |
Output dimension: 768, 512, 256, or 128. |
normalize |
L2-normalize each output row. Keep this |
truncate |
Truncate overlong inputs to the model's 2048-token context,
preserving BOS and EOS. If |
check_interrupt |
Poll for R user interrupts during tokenization and between bounded packed inference batches. |
For retrieval, prefer embeddinggemma_embed_query() and
embeddinggemma_embed_document() so query and document prompts cannot be
confused. Matryoshka dimensions 512, 256, and 128 select the leading
dimensions of the 768-vector and then re-normalize, as specified by the
model card.
An embeddingGemmaEmbeddings numeric matrix with one row per input.
Its embedding_info attribute records prompts, token counts, truncation,
dimensions, and normalization.
Encode retrieval documents with EmbeddingGemma
embeddinggemma_embed_document( model, text, title = NULL, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )embeddinggemma_embed_document( model, text, title = NULL, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )
model |
An |
text |
Character vector to embed. |
title |
Optional document-title scalar or vector. It is valid only for
|
dimensions |
Output dimension: 768, 512, 256, or 128. |
normalize |
L2-normalize each output row. Keep this |
truncate |
Truncate overlong inputs to the model's 2048-token context,
preserving BOS and EOS. If |
check_interrupt |
Poll for R user interrupts during tokenization and between bounded packed inference batches. |
An embeddingGemmaEmbeddings numeric matrix.
Encode retrieval queries with EmbeddingGemma
embeddinggemma_embed_query( model, text, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )embeddinggemma_embed_query( model, text, dimensions = 768L, normalize = TRUE, truncate = TRUE, check_interrupt = TRUE )
model |
An |
text |
Character vector to embed. |
dimensions |
Output dimension: 768, 512, 256, or 128. |
normalize |
L2-normalize each output row. Keep this |
truncate |
Truncate overlong inputs to the model's 2048-token context,
preserving BOS and EOS. If |
check_interrupt |
Poll for R user interrupts during tokenization and between bounded packed inference batches. |
An embeddingGemmaEmbeddings numeric matrix.
Inspect an EmbeddingGemma model
embeddinggemma_model_info(model)embeddinggemma_model_info(model)
model |
An |
A named list describing the architecture and supported dimensions.
Loads the dedicated, retrieval-trained gemma-embedding architecture through
the package's pure-Rust CPU backend. The implementation does not link to
'llama.cpp', 'PyTorch', the 'ONNX Runtime', or the 'SentencePiece' C++
library. Model weights remain subject to the Gemma Terms of Use.
embeddinggemma_model_load(path, num_threads = NULL)embeddinggemma_model_load(path, num_threads = NULL)
path |
Path to an EmbeddingGemma GGUF file. The supported reference
artifact is |
num_threads |
Optional Rayon global thread-pool size. This can only be set once per R process. |
An EmbeddingGemmaModel object.
Applies the same mandatory task formatting as embeddinggemma_embed() and
returns the exact BOS/content/EOS token sequence consumed by the encoder.
embeddinggemma_tokenize(model, text, task, title = NULL, truncate = TRUE)embeddinggemma_tokenize(model, text, task, title = NULL, truncate = TRUE)
model |
An |
text |
Character vector to embed. |
task |
One of |
title |
Optional document-title scalar or vector. It is valid only for
|
truncate |
Truncate overlong inputs to the model's 2048-token context,
preserving BOS and EOS. If |
A named list containing integer ids, legible token pieces, the
task-formatted text, and a truncation flag.
EmbeddingGemma loading options
EmbeddingGemmaLoadOptions(path = character(0), num_threads = NULL)EmbeddingGemmaLoadOptions(path = character(0), num_threads = NULL)
path |
Path to a |
num_threads |
Optional positive whole-number Rayon thread count. |
Loaded EmbeddingGemma GGUF model.
EmbeddingGemmaModelEmbeddingGemmaModel
EmbeddingGemma model reference
EmbeddingGemmaModelRef(value = list())EmbeddingGemmaModelRef(value = list())
value |
A one-element list containing an |
EmbeddingGemma encoding options
EmbeddingGemmaOptions( text = character(0), task = character(0), title = NULL, dimensions = integer(0), normalize = logical(0), truncate = logical(0), check_interrupt = logical(0) )EmbeddingGemmaOptions( text = character(0), task = character(0), title = NULL, dimensions = integer(0), normalize = logical(0), truncate = logical(0), check_interrupt = logical(0) )
text |
Character vector to encode. |
task |
Embedding task controlling the required model prompt. |
title |
Optional document title, used only for |
dimensions |
Matryoshka output size: 768, 512, 256, or 128. |
normalize |
Whether to L2-normalize each embedding. |
truncate |
Whether to truncate inputs exceeding the 2048-token context. |
check_interrupt |
Whether to poll R interrupts during tokenization and between bounded packed inference batches. |
Print a BebeLM generation result
## S3 method for class 'bebelGeneration' print(x, ...)## S3 method for class 'bebelGeneration' print(x, ...)
x |
A result returned by |
... |
Unused. |
Invisibly returns x.
Return feature information reported by the loaded Rust backend.
rbebelm_backend_features()rbebelm_backend_features()
Inspect Rbebelm backend dispatch state
rbebelm_backend_info()rbebelm_backend_info()
A named list describing installed, supported, requested, and selected backends,
with class rbebelmBackendInfo.
Inspect CPU SIMD support used by backend dispatch
rbebelm_cpuid_info()rbebelm_cpuid_info()
A named list of logical CPU feature checks with class rbebelmCpuidInfo.
Must be called before loading a model or querying backend features.
rbebelm_set_backend(backend = "auto")rbebelm_set_backend(backend = "auto")
backend |
One of |
The requested backend name.