tzoulio commited on
Commit
8a77f3c
·
verified ·
1 Parent(s): 7b70c23

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -190
README.md CHANGED
@@ -12,201 +12,68 @@ tags:
12
  - Articles
13
  - Political
14
  ---
 
15
 
16
- # Model Card for Model ID
 
17
 
18
- <!-- Provide a quick summary of what the model is/does. -->
19
-
20
-
21
-
22
- ## Model Details
23
-
24
- ### Model Description
25
-
26
- <!-- Provide a longer summary of what this model is. -->
27
-
28
-
29
-
30
- - **Developed by:** [More Information Needed]
31
- - **Funded by [optional]:** [More Information Needed]
32
- - **Shared by [optional]:** [More Information Needed]
33
- - **Model type:** [More Information Needed]
34
- - **Language(s) (NLP):** [More Information Needed]
35
- - **License:** [More Information Needed]
36
- - **Finetuned from model [optional]:** [More Information Needed]
37
-
38
- ### Model Sources [optional]
39
-
40
- <!-- Provide the basic links for the model. -->
41
-
42
- - **Repository:** [More Information Needed]
43
- - **Paper [optional]:** [More Information Needed]
44
- - **Demo [optional]:** [More Information Needed]
45
-
46
- ## Uses
47
-
48
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
49
-
50
- ### Direct Use
51
-
52
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
53
-
54
- [More Information Needed]
55
-
56
- ### Downstream Use [optional]
57
-
58
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
59
-
60
- [More Information Needed]
61
-
62
- ### Out-of-Scope Use
63
-
64
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
65
-
66
- [More Information Needed]
67
-
68
- ## Bias, Risks, and Limitations
69
-
70
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
71
-
72
- [More Information Needed]
73
-
74
- ### Recommendations
75
-
76
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
77
-
78
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
79
-
80
- ## How to Get Started with the Model
81
-
82
- Use the code below to get started with the model.
83
-
84
- [More Information Needed]
85
-
86
- ## Training Details
87
-
88
- ### Training Data
89
-
90
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
91
-
92
- [More Information Needed]
93
-
94
- ### Training Procedure
95
-
96
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
97
-
98
- #### Preprocessing [optional]
99
-
100
- [More Information Needed]
101
-
102
-
103
- #### Training Hyperparameters
104
-
105
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
106
-
107
- #### Speeds, Sizes, Times [optional]
108
-
109
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
110
-
111
- [More Information Needed]
112
-
113
- ## Evaluation
114
-
115
- <!-- This section describes the evaluation protocols and provides the results. -->
116
-
117
- ### Testing Data, Factors & Metrics
118
-
119
- #### Testing Data
120
-
121
- <!-- This should link to a Dataset Card if possible. -->
122
-
123
- [More Information Needed]
124
-
125
- #### Factors
126
-
127
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
128
-
129
- [More Information Needed]
130
-
131
- #### Metrics
132
-
133
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
134
-
135
- [More Information Needed]
136
-
137
- ### Results
138
-
139
- [More Information Needed]
140
-
141
- #### Summary
142
-
143
-
144
-
145
- ## Model Examination [optional]
146
-
147
- <!-- Relevant interpretability work for the model goes here -->
148
-
149
- [More Information Needed]
150
-
151
- ## Environmental Impact
152
-
153
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
154
-
155
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
156
-
157
- - **Hardware Type:** [More Information Needed]
158
- - **Hours used:** [More Information Needed]
159
- - **Cloud Provider:** [More Information Needed]
160
- - **Compute Region:** [More Information Needed]
161
- - **Carbon Emitted:** [More Information Needed]
162
-
163
- ## Technical Specifications [optional]
164
-
165
- ### Model Architecture and Objective
166
-
167
- [More Information Needed]
168
-
169
- ### Compute Infrastructure
170
-
171
- [More Information Needed]
172
-
173
- #### Hardware
174
-
175
- [More Information Needed]
176
-
177
- #### Software
178
-
179
- [More Information Needed]
180
-
181
- ## Citation [optional]
182
-
183
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
184
-
185
- **BibTeX:**
186
-
187
- [More Information Needed]
188
-
189
- **APA:**
190
-
191
- [More Information Needed]
192
-
193
- ## Glossary [optional]
194
-
195
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
196
-
197
- [More Information Needed]
198
-
199
- ## More Information [optional]
200
 
201
- [More Information Needed]
202
 
203
- ## Model Card Authors [optional]
 
 
 
204
 
205
- [More Information Needed]
 
 
 
 
 
 
 
 
206
 
207
- ## Model Card Contact
208
 
209
- [More Information Needed]
210
- ### Framework versions
211
 
212
- - PEFT 0.14.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  - Articles
13
  - Political
14
  ---
15
+ # **Llama-3.2-1B (Political Bias Detection)**
16
 
17
+ ## **Overview**
18
+ This model is designed to detect potential political bias in news articles. Given a text passage (e.g., a news article), the model returns probabilities indicating whether the text is leaning to the *Left*, *Center*, or *Right* of the political spectrum.
19
 
20
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ ## **Model Description**
23
 
24
+ ### **Model Architecture**
25
+ - **Base Model**: [meta-llama/Llama-3.2-1B](https://huggingface.co/meta-llama/Llama-3.2-1B)
26
+ - **Adapters**: LoRA (Low-Rank Adaptation)
27
+ - **Precision**: 4-bit quantization enabled for efficient inference and training (with nested/double quantization).
28
 
29
+ ### **Intended Use**
30
+ - **Primary**: Provide a text of a news article, the model outputs probabilities corresponding to three political bias labels:
31
+ - **LABEL_0**: Left
32
+ - **LABEL_1**: Center
33
+ - **LABEL_2**: Right
34
+ - **Usage Scenarios**:
35
+ - Media research and analytics
36
+ - Automated or semi-automated political bias detection in digital news
37
+ - Educational or journalistic explorations of bias
38
 
39
+ > **Note**: This model is *not* an authoritative arbiter of political bias. It can be used as a *supplementary* tool to help flag potential leanings.
40
 
41
+ ---
 
42
 
43
+ ## **How to Use**
44
+
45
+ Below is a sample code snippet demonstrating how to load the model and apply LoRA adapters for classification:
46
+
47
+ ```python
48
+ import torch
49
+ import transformers
50
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
51
+ from peft import PeftModel
52
+
53
+ # 1. Load the *base* LLaMA model for sequence classification
54
+ base_model_name = "meta-llama/Llama-3.2-1B"
55
+ access_token = "YOUR_HF_ACCESS_TOKEN" # If needed
56
+
57
+ model = AutoModelForSequenceClassification.from_pretrained(
58
+ base_model_name,
59
+ use_auth_token=access_token,
60
+ num_labels=3,
61
+ device_map="auto"
62
+ )
63
+ tokenizer = AutoTokenizer.from_pretrained(base_model_name)
64
+
65
+ # 2. Load the LoRA adapter on top of the base model
66
+ adapter_path = "path/to/your/lora/adapter"
67
+ model = PeftModel.from_pretrained(model, adapter_path)
68
+
69
+ # 3. Create the pipeline with the specified model and tokenizer
70
+ pipeline = transformers.pipeline(
71
+ "text-classification",
72
+ model=model,
73
+ tokenizer=tokenizer
74
+ )
75
+
76
+ # Example usage
77
+ text = "Insert the news article text here..."
78
+ prediction = pipeline(text)
79
+ print(prediction)