Views
No views yet
1# Base (no inference backend)
2pip install neural-txt
3
4# With HuggingFace backend (torch)
5pip install neural-txt[hf]
6
7# With MLX backend (Apple Silicon)
8pip install neural-txt[mlx]1from neuraltxt import NeuralTxt
2
3model = NeuralTxt(backend="mlx") # or backend="hf"
4
5passage = """
6Transformers have revolutionized NLP by introducing the self-attention
7mechanism. Unlike RNNs, transformers process all tokens in parallel,
8leading to significant training speedups.
9"""
10
11# Extract key points
12bullets = model.extract_bullets(passage)
13
14# Generate question-answer pairs
15pairs = model.generate_qa_pairs(passage)
16
17# Extract knowledge graph triplets
18triplets = model.extract_triplets(passage)json=True for guaranteed structured output via outlines:1# Returns a BulletsOutput pydantic model
2bullets = model.extract_bullets(passage, json=True)
3print(bullets.bullets) # list[str]
4
5# Returns a QAPairsOutput pydantic model
6qa = model.generate_qa_pairs(passage, json=True)
7for pair in qa.pairs:
8 print(pair.question, pair.answer)
9
10# Returns a TripletsOutput pydantic model
11triplets = model.extract_triplets(passage, json=True)
12for t in triplets.triplets:
13 print(t.subject, t.relation, t.object)| Method | Input | Output | JSON Output |
|---|---|---|---|
extract_bullets(passage) | passage | list[str] | BulletsOutput |
generate_qa_pairs(passage) | passage | list[QAPair] | QAPairsOutput |
generate_question(passage) | passage | str | QuestionOutput |
generate_questions_list(passage) | passage | list[str] | QuestionsListOutput |
extract_fact(passage) | passage | str | FactOutput |
answer(question, passage) | question + passage | str | AnswerOutput |
rephrase(passage) | passage | str | RephraseOutput |
continue_from(passage) | passage start | str | ContinuationOutput |
extract_triplets(passage) | passage | list[Triplet] | TripletsOutput |
compare(passage_a, passage_b) | two passages | str | ComparisonOutput |
find_relevant(question, passages) | question + passage list | RetrievalResult | RetrievalOutput |
| Model | Overall | Faithful. | Correct. | Relev. | Complete |
|---|---|---|---|---|---|
| neuraltxt (135M) | 3.52 | 3.98 | 3.12 | 3.88 | 3.12 |
| Qwen3.5-0.8B (4-bit) | 3.35 | 3.75 | 2.98 | 3.85 | 2.81 |
| Qwen3.5-4B (4-bit) | 3.31 | 3.99 | 3.16 | 3.24 | 2.84 |
| Qwen3-0.6B | 3.31 | 3.64 | 3.04 | 3.74 | 2.83 |
| SmolLM2-135M-Instruct | 2.38 | 2.73 | 2.15 | 2.63 | 1.99 |