FreeFormExtractor

org.llm4s.knowledgegraph.extraction.FreeFormExtractor
class FreeFormExtractor(llmClient: LLMClient)

Extracts a Knowledge Graph from unstructured text with a free-form LLM prompt, and returns it without storing it.

The node ids in the result are the model's own, usually 1, 2, ..., so they collide across documents: give each document's graph a namespace before merging or storing it, as SourceTrackedGraph.addDocument and KnowledgeGraphGenerator.extract do.

Value parameters

llmClient

The LLM client to use for extraction

Attributes

Example
val extractor = new FreeFormExtractor(llmClient)
val result = extractor.extract(
 text = "Alice works at Acme Corp in San Francisco.",
 entityTypes = List("Person", "Organization", "Location")
)
Source
FreeFormExtractor.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def extract(text: String, entityTypes: List[String], relationTypes: List[String]): Result[Graph]

Extracts entities and relationships from the given text.

Extracts entities and relationships from the given text.

Value parameters

entityTypes

Optional list of entity types to focus on (e.g., "Person", "Organization")

relationTypes

Optional list of relationship types to look for

text

The text to analyze

Attributes

Returns

Right(extractedGraph) on success, Left(ProcessingError) on failure

Source
FreeFormExtractor.scala