LlmPropositionExtractor

data class LlmPropositionExtractor(llmOptions: <Error class: unknown class>, ai: <Error class: unknown class>, template: String = "dice/extract_propositions", examples: List<<Error class: unknown class><PropositionsResult>> = emptyList(), val schemaAdherence: SchemaAdherence = SchemaAdherence.DEFAULT, val existingPropositionsToShow: Int = 100, propositionRepository: PropositionRepository? = null, val perspective: ExtractionPerspective = ExtractionPerspective.ALL) : PropositionExtractor, ExtractionConfig

LLM-based proposition extractor. Uses a Jinja template to extract propositions from chunks.

Custom Templates

Custom templates can include the default template and add domain-specific focus:

{% include "dice/extract_propositions.jinja" %}

FOCUS:

Extract facts about the user and the user's musical preferences:

- The user's level of knowledge about music theory
- Favorite genres, artists, and songs
- Instruments they play or want to learn
- Listening habits and contexts
...

Parameters

llmOptions

LLM configuration

ai

AI service for LLM calls

template

Template name for proposition extraction. Unless the TemplateResolver in use has been customized, this will be the path to a Jinja template under /src/main/resources/prompts. The templates should expect an object of type TemplateModel as input with name "model". The default is "dice/extract_propositions". Users can override this or use it as an example for a custom template.

examples

Optional list of examples for few-shot prompting.

schemaAdherence

Configuration for how strictly to adhere to the schema for entities and predicates.

existingPropositionsToShow

Number of existing propositions to show in the prompt.

propositionRepository

Optional repository to fetch existing propositions from. When provided, existing propositions for the context will be included in the prompt to help the LLM avoid duplicates and maintain consistency.

perspective

Controls whose perspective propositions are extracted from. See ExtractionPerspective.

Constructors

Link copied to clipboard
constructor(llmOptions: <Error class: unknown class>, ai: <Error class: unknown class>, template: String = "dice/extract_propositions", examples: List<<Error class: unknown class><PropositionsResult>> = emptyList(), schemaAdherence: SchemaAdherence = SchemaAdherence.DEFAULT, existingPropositionsToShow: Int = 100, propositionRepository: PropositionRepository? = null, perspective: ExtractionPerspective = ExtractionPerspective.ALL)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Backward compatibility: returns true if entities should be locked to schema.

Link copied to clipboard
Link copied to clipboard
open override val schemaAdherence: SchemaAdherence

Functions

Link copied to clipboard
open override fun extract(chunk: <Error class: unknown class>, context: SourceAnalysisContext): SuggestedPropositions

Extract propositions from a chunk using LLM.

Link copied to clipboard
open override fun resolvePropositions(suggestedPropositions: SuggestedPropositions, resolutions: Resolutions<SuggestedEntityResolution>, context: SourceAnalysisContext): List<Proposition>

Apply entity resolution results to create final Propositions.

Link copied to clipboard
open override fun toSuggestedEntities(suggestedPropositions: SuggestedPropositions, context: SourceAnalysisContext, sourceText: String?, mentionFilter: MentionFilter?): SuggestedEntities

Convert mentions from suggested propositions to SuggestedEntities for use with the existing EntityResolver.

Link copied to clipboard
fun withExample(example: <Error class: unknown class><PropositionsResult>): LlmPropositionExtractor
Link copied to clipboard
fun withExamples(examples: List<<Error class: unknown class><PropositionsResult>>): LlmPropositionExtractor
Link copied to clipboard

Set the number of existing propositions to show in prompts.

Link copied to clipboard

Set the extraction perspective. Controls whose facts are extracted from conversational text. See ExtractionPerspective.

Link copied to clipboard

Set the proposition repository to fetch existing propositions from. When provided, existing propositions for the context will be included in the prompt.

Link copied to clipboard

Set the schema adherence configuration.

Link copied to clipboard