EmbeddingBatching

org.llm4s.rag.embed.EmbeddingBatching
See theEmbeddingBatching companion object
@Experimental
final case class EmbeddingBatching(maxInputs: Int, maxChars: Int)

How many texts, and how many characters, one embedding request may carry (#3001). Providers cap a request's inputs (Cohere 96, Voyage 128, OpenAI 2,048) and its tokens (OpenAI 300,000), and reject a larger one outright, so a document of a few thousand chunks failed to ingest as a whole. The pipeline splits the texts into requests within both bounds; the defaults are below every provider llm4s ships.

Value parameters

maxChars

the most characters in one request, summed over its texts: a token budget, at roughly four characters a token. A single text longer than this goes alone in its request

maxInputs

the most texts in one request; at least 1

Attributes

Companion
object
Source
EmbeddingBatching.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def batches(texts: Seq[String]): Seq[(Int, Seq[String])]

texts in consecutive groups within both bounds, each with the index of its first text.

texts in consecutive groups within both bounds, each with the index of its first text.

Attributes

Source
EmbeddingBatching.scala
def embedAll[A](texts: Seq[String])(embed: Seq[String] => Result[Seq[A]])(describe: (LLMError, Int, Int) => LLMError): Result[Seq[A]]

Embeds texts batch by batch with embed, in order, stopping at the first failure. A failed request of one text names that text's index, so a chunk the model refuses is identified.

Embeds texts batch by batch with embed, in order, stopping at the first failure. A failed request of one text names that text's index, so a chunk the model refuses is identified.

Attributes

Source
EmbeddingBatching.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product