poperskop commited on
Commit
3124237
1 Parent(s): 508b0a1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -4
README.md CHANGED
@@ -20,12 +20,16 @@ Labels:
20
  ## Usage
21
 
22
  ``` python
23
- from transformers import AutoTokenizer
 
 
 
 
24
 
25
  HF_MODEL_NAME = 'poc-embeddings/rubert-tiny-turbo-godeal'
26
  MODEL_NAME = 'sergeyzh/rubert-tiny-turbo'
27
 
28
- id2label = {0:'noise', 1:'demand', 2:'noise'}
29
 
30
  class SupplyDemandTrader(
31
  Module,
@@ -92,9 +96,11 @@ model = SupplyDemandTrader.from_pretrained(HF_MODEL_NAME)
92
  tokenizer = AutoTokenizer.from_pretrained(HF_MODEL_NAME)
93
  model.eval()
94
 
 
 
95
  with torch.inference_mode():
96
- ids = tokenizer("Куплю Iphone 8", return_tensors="pt")
97
- logits = checkpoint.forward(ids['input_ids'], ids['attention_mask']))
98
  preds = torch.argmax(logits)
99
  print(id2label[int(preds)])
100
  ```
 
20
  ## Usage
21
 
22
  ``` python
23
+ from transformers import AutoModel, AutoTokenizer
24
+ import torch
25
+ from torch.nn import Linear, Module, TransformerEncoderLayer, CrossEntropyLoss
26
+ from huggingface_hub import PyTorchModelHubMixin
27
+ from typing import Optional
28
 
29
  HF_MODEL_NAME = 'poc-embeddings/rubert-tiny-turbo-godeal'
30
  MODEL_NAME = 'sergeyzh/rubert-tiny-turbo'
31
 
32
+ id2label = {0:'noise', 1:'supply', 2:'demand'}
33
 
34
  class SupplyDemandTrader(
35
  Module,
 
96
  tokenizer = AutoTokenizer.from_pretrained(HF_MODEL_NAME)
97
  model.eval()
98
 
99
+ message = "Куплю Iphone 8"
100
+
101
  with torch.inference_mode():
102
+ ids = tokenizer(message, return_tensors="pt")
103
+ logits = model.forward(ids['input_ids'], ids['attention_mask'])['logits']
104
  preds = torch.argmax(logits)
105
  print(id2label[int(preds)])
106
  ```