Instructions to use ibm-granite/granitelib-rag-r1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Granite Library
How to use ibm-granite/granitelib-rag-r1.0 with Granite Library:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Upload io.yaml
Browse files
hallucination_detection/granite-4.0-micro/lora/io.yaml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Model name string, or null to use whatever is provided in the chat completion request
|
| 2 |
+
model: ~
|
| 3 |
+
# JSON schema of the model's output
|
| 4 |
+
response_format: |
|
| 5 |
+
{
|
| 6 |
+
"$defs": {
|
| 7 |
+
"HallucinationOutputEntry": {
|
| 8 |
+
"properties": {
|
| 9 |
+
"r": {
|
| 10 |
+
"minimum": 0,
|
| 11 |
+
"title": "Sentence Num",
|
| 12 |
+
"type": "integer"
|
| 13 |
+
},
|
| 14 |
+
"f": {
|
| 15 |
+
"title": "Is Faithful",
|
| 16 |
+
"type": "string",
|
| 17 |
+
"enum": ["faithful", "partial", "unfaithful"]
|
| 18 |
+
},
|
| 19 |
+
"e": {
|
| 20 |
+
"title": "Reasoning",
|
| 21 |
+
"type": "string"
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"required": [
|
| 25 |
+
"r",
|
| 26 |
+
"e",
|
| 27 |
+
"f"
|
| 28 |
+
],
|
| 29 |
+
"title": "HallucinationOutputEntry",
|
| 30 |
+
"type": "object"
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"items": {
|
| 34 |
+
"$ref": "#/$defs/HallucinationOutputEntry"
|
| 35 |
+
},
|
| 36 |
+
"title": "HallucinationOutput",
|
| 37 |
+
"type": "array"
|
| 38 |
+
}
|
| 39 |
+
transformations:
|
| 40 |
+
# Use logprobs to replace "f" flag with a probability
|
| 41 |
+
- type: likelihood
|
| 42 |
+
categories_to_values:
|
| 43 |
+
"faithful": 1.0
|
| 44 |
+
"partial": 0.5
|
| 45 |
+
"unfaithful": 0.0
|
| 46 |
+
input_path: [~, "f"] # Null in path means wildcard
|
| 47 |
+
# Replace sentence number with sentence location and contents
|
| 48 |
+
- type: decode_sentences
|
| 49 |
+
source: "last_message"
|
| 50 |
+
input_path: [~, "r"] # Null in path means wildcard
|
| 51 |
+
# New fields to add for each sentence
|
| 52 |
+
output_names:
|
| 53 |
+
begin: "response_begin"
|
| 54 |
+
end: "response_end"
|
| 55 |
+
text: "response_text"
|
| 56 |
+
# Remove fields that we no longer need and rename some of the fields.
|
| 57 |
+
- type: project
|
| 58 |
+
input_path: []
|
| 59 |
+
retained_fields:
|
| 60 |
+
"response_begin": "response_begin"
|
| 61 |
+
"response_end": "response_end"
|
| 62 |
+
"response_text": "response_text"
|
| 63 |
+
"f": "faithfulness_likelihood"
|
| 64 |
+
"e": "explanation"
|
| 65 |
+
instruction: >
|
| 66 |
+
Split the last assistant response into individual sentences.
|
| 67 |
+
For each sentence in the last assistant response, identify the faithfulness
|
| 68 |
+
by comparing with the provided documents and generate the faithfulness reasoning
|
| 69 |
+
and faithfulness decision.
|
| 70 |
+
Ensure that your output includes all response sentence IDs,
|
| 71 |
+
and for each response sentence ID, provide the corresponding faithfulness
|
| 72 |
+
reasoning and faithfulness decision.
|
| 73 |
+
The output must be a json structure.
|
| 74 |
+
parameters:
|
| 75 |
+
# Current LoRA can be quite verbose in its explanations.
|
| 76 |
+
max_completion_tokens: 4096
|
| 77 |
+
sentence_boundaries:
|
| 78 |
+
last_message: "i"
|