File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -47,19 +47,29 @@ dataset = load_dataset("ag_news")
47
47
example = dataset[" train" ][0 ]
48
48
49
49
# Prompt it
50
- from promptsource.templates import TemplateCollection
51
- # Get all the prompts
52
- collection = TemplateCollection()
50
+ from promptsource.templates import DatasetTemplates
53
51
# Get all the AG News prompts
54
- ag_news_prompts = collection.get_dataset( " ag_news" )
52
+ ag_news_prompts = DatasetTemplates( ' ag_news' )
55
53
# Select a prompt by name
56
54
prompt = ag_news_prompts[" classify_question_first" ]
57
-
55
+ # Apply the prompt on the example
58
56
result = prompt.apply(example)
59
57
print (" INPUT: " , result[0 ])
60
58
print (" TARGET: " , result[1 ])
61
59
```
62
60
61
+ You can collect all the available datasets and their associated prompts
62
+
63
+ ``` python
64
+ from promptsource.templates import TemplateCollection
65
+
66
+ # Get all the prompts
67
+ collection = TemplateCollection()
68
+
69
+ # Return a dict where the key is the pair (dataset name, subset name)
70
+ # and the value is an instance of DatasetTemplates
71
+ print (collection.datasets_templates)
72
+ ```
63
73
## Contributing
64
74
Contribution guidelines and step-by-step * HOW TO* are described [ here] ( CONTRIBUTING.md ) .
65
75
You can’t perform that action at this time.
0 commit comments