DetectiveShadow commited on
Commit
d13bee7
·
verified ·
1 Parent(s): 2982e3f

Create Familytrainer

Browse files
Files changed (1) hide show
  1. Familytrainer +36 -0
Familytrainer ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install transformers datasets
2
+ from datasets import load_dataset
3
+
4
+ # Load the dataset
5
+ dataset = load_dataset("DetectiveShadow/ShadowFamily")
6
+
7
+ # Inspect the dataset structure
8
+ print(dataset)
9
+
10
+ sample = dataset["train"][0] # Get the first example
11
+ print(sample)
12
+
13
+ from transformers import pipeline
14
+
15
+ # Load the QA pipeline with the model
16
+ qa_pipeline = pipeline("question-answering", model="DetectiveShadow/QuestBoard")
17
+
18
+ # Example: Use the first entry from the dataset
19
+ question = dataset["train"][0]["question"] # Extract question
20
+ context = dataset["train"][0]["context"] # Extract context
21
+
22
+ # Get the answer from the model
23
+ result = qa_pipeline(question=question, context=context)
24
+
25
+ # Print the result
26
+ print(f"Question: {question}")
27
+ print(f"Answer: {result['answer']}")
28
+
29
+ for entry in dataset["train"]:
30
+ question = entry["question"]
31
+ context = entry["context"]
32
+
33
+ result = qa_pipeline(question=question, context=context)
34
+
35
+ print(f"Question: {question}")
36
+ print(f"Answer: {result['answer']}\n")