srush commited on
Commit
7365157
·
1 Parent(s): 586f008

Upload with huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +30 -23
  2. ner.pmpt.tpl +1 -3
app.py CHANGED
@@ -28,30 +28,37 @@ class TeamPrompt(minichain.Prompt):
28
  # Run the system.
29
 
30
  with minichain.start_chain("ner") as backend:
31
- p1 = NERPrompt(backend.OpenAI())
32
- p2 = TeamPrompt(backend.OpenAI())
33
- prompt = p1.chain(p2)
34
- results = prompt(
35
- {"text_input": "An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.",
36
- "labels" : ["Team", "Date"],
37
- "domain": "Sports"
38
- }
39
- )
40
- print(results)
41
 
 
 
 
 
 
 
 
42
  # View prompt examples.
43
 
44
  # + tags=["hide_inp"]
45
- NERPrompt().show(
46
- {
47
- "input": "I went to New York",
48
- "domain": "Travel",
49
- "labels": ["City"]
50
- },
51
- '[{"T": "City", "E": "New York"}]',
52
- )
53
- # -
54
-
55
- # View log.
56
-
57
- minichain.show_log("ner.log")
 
28
  # Run the system.
29
 
30
  with minichain.start_chain("ner") as backend:
31
+ ner_prompt = NERPrompt(backend.OpenAI())
32
+ team_prompt = TeamPrompt(backend.OpenAI())
33
+ prompt = ner_prompt.chain(team_prompt)
34
+ # results = prompt(
35
+ # {"text_input": "An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.",
36
+ # "labels" : ["Team", "Date"],
37
+ # "domain": "Sports"
38
+ # }
39
+ # )
40
+ # print(results)
41
 
42
+ ner_prompt.set_display_options(markdown=True)
43
+ team_prompt.set_display_options(markdown=True)
44
+
45
+ prompt.to_gradio(fields =["text_input", "labels", "domain"],
46
+ examples=[["An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.", "Team, Date", "Sports"]]).launch()
47
+
48
+
49
  # View prompt examples.
50
 
51
  # + tags=["hide_inp"]
52
+ # NERPrompt().show(
53
+ # {
54
+ # "input": "I went to New York",
55
+ # "domain": "Travel",
56
+ # "labels": ["City"]
57
+ # },
58
+ # '[{"T": "City", "E": "New York"}]',
59
+ # )
60
+ # # -
61
+
62
+ # # View log.
63
+
64
+ # minichain.show_log("ner.log")
ner.pmpt.tpl CHANGED
@@ -1,8 +1,6 @@
1
  You are a highly intelligent and accurate {{ domain }} domain Named-entity recognition(NER) system. You take Passage as input and your task is to recognize and extract specific types of {{ domain }} domain named entities in that given passage and classify into a set of following predefined entity types:
2
 
3
- {% for l in labels %}
4
- * {{ l }}
5
- {% endfor %}
6
 
7
  Your output format is only {{ output_format|default('[{"T": type of entity from predefined entity types, "E": entity in the input text}]') }} form, no other form.
8
 
 
1
  You are a highly intelligent and accurate {{ domain }} domain Named-entity recognition(NER) system. You take Passage as input and your task is to recognize and extract specific types of {{ domain }} domain named entities in that given passage and classify into a set of following predefined entity types:
2
 
3
+ {{labels}}
 
 
4
 
5
  Your output format is only {{ output_format|default('[{"T": type of entity from predefined entity types, "E": entity in the input text}]') }} form, no other form.
6