(no commit message)

This commit is contained in:
2026-04-02 18:09:22 -07:00
parent 21111b7748
commit 62553c714a
6 changed files with 74 additions and 2 deletions

View File

@@ -1,2 +0,0 @@
# doc-extract

4
auto_classes.json Normal file
View File

@@ -0,0 +1,4 @@
{
"AutoConfig": "modaic.PrecompiledConfig",
"AutoProgram": "program.DocExtract"
}

3
config.json Normal file
View File

@@ -0,0 +1,3 @@
{
"model": null
}

32
program.json Normal file
View File

@@ -0,0 +1,32 @@
{
"cot.predict": {
"traces": [],
"train": [],
"demos": [],
"signature": {
"instructions": "Classify a document snippet into one of the supported label buckets.",
"fields": [
{
"prefix": "Context:",
"description": "Document text or snippet to classify"
},
{
"prefix": "Reasoning: Let's think step by step in order to",
"description": "${reasoning}"
},
{
"prefix": "Label:",
"description": "Return exactly one of: legal, healthcare, personal, tax, or other"
}
]
},
"lm": null
},
"metadata": {
"dependency_versions": {
"python": "3.11",
"dspy": "3.1.3",
"cloudpickle": "3.1"
}
}
}

28
program.py Normal file
View File

@@ -0,0 +1,28 @@
# Here you can define your dspy.Module as a modaic.PrecompiledProgram
from typing import Literal
import dspy
from modaic import PrecompiledProgram
DocumentLabel = Literal["legal", "healthcare", "personal", "tax", "other"]
class ExtractSignature(dspy.Signature):
"""Classify a document snippet into one of the supported label buckets."""
context: str = dspy.InputField(desc="Document text or snippet to classify")
label: DocumentLabel = dspy.OutputField(
desc="Return exactly one of: legal, healthcare, personal, tax, or other"
)
class DocExtract(PrecompiledProgram):
def __init__(self):
super().__init__()
self.cot = dspy.ChainOfThought(ExtractSignature)
def forward(self, context: str) -> dspy.Prediction:
return self.cot(context=context)
DocExtract().push_to_hub("tyrin/doc-extract")

7
pyproject.toml Normal file
View File

@@ -0,0 +1,7 @@
[project]
name = "doc-extract"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = ["dspy>=3.1.3", "modaic>=0.29.1"]