Arpan Chatterjee commited on
Commit
5f20c72
β€’
1 Parent(s): 840725d

Modified trained model path

Browse files
app.py CHANGED
@@ -1,13 +1,35 @@
1
  import streamlit as st
2
  import pandas as pd
 
 
 
3
 
4
- #_METADATA_PATH = "https://huggingface.co/datasets/HUPD/hupd/resolve/main/hupd_metadata_2022-02-22.feather"
5
- # Read the feather
6
- #df = pd.read_feather(_METADATA_PATH)
7
  df = pd.read_pickle("my_dataframe.pkl")
8
  print(df.head(5))
9
  print(df["abstract"][4])
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  '''
12
  x = st.slider('Select a value')
13
  st.write(x, 'squared is', x * x)
 
1
  import streamlit as st
2
  import pandas as pd
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
+ import torch
5
+ import torch.nn.functional as F
6
 
 
 
 
7
  df = pd.read_pickle("my_dataframe.pkl")
8
  print(df.head(5))
9
  print(df["abstract"][4])
10
 
11
+ model_dir = 'model-patent-score'
12
+ tokenizer = AutoTokenizer.from_pretrained(model_dir)
13
+ model = AutoModelForSequenceClassification.from_pretrained(model_dir)
14
+
15
+ abstract = "The present invention relates to passive optical network (PON), and in particular, to an optical network terminal (ONT) in the PON system. In one embodiment, the optical network terminal includes a first interface coupled to a communications network, a second interface coupled to a network client and a processor including a memory coupled to the first interface and to the second interface, wherein the processor is capable of converting optical signals to electric signals, such that the network client can access the communications network."
16
+ #abstract = "A shoe midsole is composed of a base plate (1), a cover (2), a plurality of blades (3), and liquid (4). The blades (3) are formed in such a manner as to rise within a first region (11) of the base plate (1). The blades (3) are each composed of a plurality of flat-shaped blade elements (32, 33) separated each other by slits (31), and are tilted toward the toe side or the heel side. The flat-shaped blade elements (32, 33) are disposed in such a manner as to be divergent toward the toe side or the heel side. The base plate (1) and the cover (2) are joined together, thereby forming a closed space (5), and the liquid (4) is sealed in the closed space."
17
+ inputs = tokenizer.encode_plus(abstract, max_length=512, padding='max_length', truncation=True, return_tensors='pt')
18
+
19
+ # Get the model prediction
20
+ outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
21
+ scores = torch.softmax(outputs.logits, dim=1)[0]
22
+
23
+
24
+ probs = F.softmax(scores, dim=0)
25
+ # Print the scores
26
+ accept_prob = probs[1].item()
27
+ print(accept_prob)
28
+
29
+ print(outputs)
30
+ print(scores)
31
+ print(probs)
32
+
33
  '''
34
  x = st.slider('Select a value')
35
  st.write(x, 'squared is', x * x)
model-patent-score/{model-patent-score/config.json β†’ config.json} RENAMED
File without changes
model-patent-score/{model-patent-score/pytorch_model.bin β†’ pytorch_model.bin} RENAMED
File without changes
model-patent-score/{model-patent-score/special_tokens_map.json β†’ special_tokens_map.json} RENAMED
File without changes
model-patent-score/{model-patent-score/tokenizer.json β†’ tokenizer.json} RENAMED
File without changes
model-patent-score/{model-patent-score/tokenizer_config.json β†’ tokenizer_config.json} RENAMED
File without changes
model-patent-score/{model-patent-score/training_args.bin β†’ training_args.bin} RENAMED
File without changes
model-patent-score/{model-patent-score/vocab.txt β†’ vocab.txt} RENAMED
File without changes