helliun commited on
Commit
156bdeb
1 Parent(s): 97305bf

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BART-perspectives Model
2
+
3
+ ## Overview
4
+
5
+ The BART-perspectives model is a sequence-to-sequence Transformer model hosted on Hugging Face Model Hub. Built on top of Facebook's BART-large (specifically the `philschmid/bart-large-cnn-samsum` finetune), it is specifically designed to extract perspectives from textual data at scale. The model provides an in-depth analysis of the speaker's identity, their emotions, the object of these emotions, and the reason behind these emotions.
6
+
7
+ ## Usage
8
+
9
+ It is designed to be used with the `perspectives` library:
10
+
11
+ ```python
12
+ from perspectives import DataFrame
13
+
14
+ # Load DataFrame
15
+ df = DataFrame(texts = [list of sentences])
16
+
17
+ # Load model
18
+ df.load_model()
19
+
20
+ # Get perspectives
21
+ df.get_perspectives()
22
+
23
+ # Search
24
+ df.search(speaker='...', emotion='...')
25
+ ```
26
+
27
+ You can use also this model directly with a pipeline for text generation:
28
+
29
+ ```python
30
+ from transformers import pipeline
31
+
32
+ # Load the model
33
+ generator = pipeline('text-generation', model='helliun/bart-perspectives')
34
+
35
+ # Get perspective
36
+ perspective = generator("Describe the perspective of this text: <your text>", max_length=1024, do_sample=False)
37
+ print(perspective)
38
+ ```
39
+ You can also use it with `transformers.AutoTokenizer` and `transformers.AutoModelForSeq2SeqLM`:
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
43
+
44
+ # Load the model
45
+ tokenizer = AutoTokenizer.from_pretrained("helliun/bart-perspectives")
46
+ model = AutoModelForSeq2SeqLM.from_pretrained("helliun/bart-perspectives")
47
+
48
+ # Tokenize the sentence
49
+ inputs = tokenizer.encode("Describe the perspective for this sentence: <your text>", return_tensors='pt')
50
+
51
+ # Pass the tensor through the model
52
+ results = model.generate(inputs)
53
+
54
+ # Decode the results
55
+ decoded = tokenizer.decode(results[:,0])
56
+ print(decoded)
57
+ ```
58
+
59
+ ## Training and Evaluation
60
+
61
+ The model was fine-tuned on a diverse corpus encompassing multiple subjects and emotion ranges. Please refer to the model's card on Hugging Face for detailed information about specific datasets, metrics, training, and evaluation processes.
62
+
63
+ ## Contributing and Support
64
+
65
+ Please raise an issue on the [Hugging Face Model card](https://huggingface.co/helliun/bart-perspectives) if you encounter any problems using the model. Contributions like fine-tuning on additional data or improving the model architecture are always welcome!
66
+
67
+ ## License
68
+
69
+ The model is open source and free to use under the MIT license.