yirmibesogluz commited on
Commit
91a6027
·
1 Parent(s): 35a7872

Added the NLI task

Browse files
Files changed (2) hide show
  1. app.py +2 -0
  2. apps/nli.py +28 -0
app.py CHANGED
@@ -11,6 +11,7 @@ import apps.categorization
11
  import apps.ner
12
  import apps.pos_tagging
13
  import apps.sts
 
14
  import apps.turna
15
 
16
  st.set_page_config(
@@ -29,6 +30,7 @@ PAGES = {
29
  "Named Entity Recognition": apps.ner,
30
  "Part-of-Speech Tagging": apps.pos_tagging,
31
  "Semantic Textual Similarity": apps.sts,
 
32
  "Text Generation": apps.turna,
33
  }
34
 
 
11
  import apps.ner
12
  import apps.pos_tagging
13
  import apps.sts
14
+ import apps.nli
15
  import apps.turna
16
 
17
  st.set_page_config(
 
30
  "Named Entity Recognition": apps.ner,
31
  "Part-of-Speech Tagging": apps.pos_tagging,
32
  "Semantic Textual Similarity": apps.sts,
33
+ "Natural Language Inference": apps.nli,
34
  "Text Generation": apps.turna,
35
  }
36
 
apps/nli.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import streamlit as st
3
+ import time
4
+ from transformers import pipeline
5
+ import os
6
+ from .utils import query
7
+
8
+ HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
9
+ headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}
10
+
11
+ def write():
12
+
13
+ st.markdown("# Natural Language Inference")
14
+ st.sidebar.header("Natural Language Inference")
15
+ st.write(
16
+ """Here, you can perform Natural Language Inference using the fine-tuned TURNA NLI model. """
17
+ )
18
+
19
+ hypothesis = st.text_area(label='Hypothesis: ', height=50,
20
+ value="Bunu nereden biliyorsun? Bütün bunlar yine onların bilgileri.")
21
+ premise = st.text_area(label='Premise: ', height=50,
22
+ value="Bu bilgi onlara ait.")
23
+ url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/turna_nli_nli_tr")
24
+ params = {"max_new_tokens": 8 }
25
+ if st.button("Generate"):
26
+ with st.spinner('Generating...'):
27
+ output = query(f"hipotez: {hypothesis} önerme: {premise}", url, params)
28
+ st.success(output)