Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 499 additions & 3 deletions deepfabric/cli.py

Large diffs are not rendered by default.

44 changes: 43 additions & 1 deletion deepfabric/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings

from typing import Literal
from typing import Literal, Self
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Self type was added in Python 3.11. To maintain compatibility with Python 3.10 as specified in pyproject.toml, you should import Self from typing_extensions for versions older than 3.11.

Suggested change
from typing import Literal, Self
from typing import Literal
from typing_extensions import Self


import yaml

Expand Down Expand Up @@ -80,6 +80,43 @@ class LLMConfig(BaseModel):
)


class ScoringConfig(BaseModel):
"""Configuration for topic graph scoring and pruning."""

parent_coherence: float = Field(
default=0.25, ge=0.0, le=1.0, description="Flag nodes with parent coherence below this"
)
sibling_coherence_lower: float = Field(
default=0.2,
ge=0.0,
le=1.0,
description="Flag nodes with sibling coherence below this (outliers)",
)
sibling_coherence_upper: float = Field(
default=0.68,
ge=0.0,
le=1.0,
description="Flag nodes with sibling coherence above this (repetitive)",
)
prune: bool = Field(
default=True, description="Whether to prune flagged nodes (false = score and report only)"
)
save_report: bool = Field(default=False, description="Save score report JSON alongside graph")
embedding_model: str = Field(
default="all-MiniLM-L6-v2", description="SentenceTransformer model for missing embeddings"
)
embedding_key: str = Field(default="embedding", description="Metadata key for node embeddings")

@model_validator(mode="after")
def validate_sibling_coherence_ordering(self) -> Self:
if self.sibling_coherence_lower >= self.sibling_coherence_upper:
raise ValueError(
f"sibling_coherence_lower ({self.sibling_coherence_lower}) "
f"must be less than sibling_coherence_upper ({self.sibling_coherence_upper})"
)
return self


class TopicsConfig(BaseModel):
"""Configuration for topic generation (tree or graph mode)."""

Expand Down Expand Up @@ -126,6 +163,11 @@ class TopicsConfig(BaseModel):
default=None, description="Optional LLM configuration overrides for topics"
)

# Optional scoring configuration (graph mode only)
scoring: ScoringConfig | None = Field(
default=None, description="Topic graph scoring and pruning configuration"
)


class ConversationConfig(BaseModel):
"""Configuration for conversation structure in generation."""
Expand Down
Loading