File size: 9,397 Bytes
e2c3421
f243196
 
 
 
 
 
 
 
 
 
 
 
 
e2c3421
f243196
5f92107
f243196
8616d21
f243196
 
 
 
6ed27aa
f243196
 
 
6ed27aa
f243196
 
 
5cd1dc4
 
 
 
f243196
 
 
 
6566cf4
 
 
6ed27aa
6566cf4
 
21b6b8d
f243196
 
 
 
 
6ed27aa
 
f243196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ed27aa
f243196
 
1d76634
f243196
 
 
 
 
6ed27aa
f243196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ed27aa
f243196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ed27aa
f243196
 
 
 
 
 
 
 
 
 
 
 
 
 
6ed27aa
f243196
 
 
 
 
 
 
 
 
 
 
 
6ed27aa
f243196
 
 
 
 
 
 
 
 
 
 
 
 
 
5cd1dc4
f243196
03ac24a
 
 
 
 
 
 
 
f243196
5cd1dc4
f243196
 
 
 
 
6ed27aa
03ac24a
f243196
03ac24a
 
 
f243196
03ac24a
6ed27aa
03ac24a
 
 
 
5c9183e
 
f51629b
9980e02
f51629b
 
 
 
 
 
 
 
9980e02
5c9183e
f51629b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
---
language:
- en
datasets:
- AIVision360
tags:
- summarization
- classification
- translation
- NLP
- media and journalism
- domain specific llm
license: apache-2.0
pipeline_tag: text-generation
---

# Llama2-7B-AIVision360 (News Connect)

NewsConnect 7B (Llama2-7B-AIVision360) is a state-of-the-art, open-source chat model that stands as a beacon for technology, media, and AI news discussions. Built on the robust Llama2-7B architecture, this  model has been enhanced and refined utilizing the AIVision360-8k dataset, making it a pioneer in the domain of AI news generation and interpretation.

## Model Details

- Architecture: Llama2-7B
- Training Dataset: [AIVision360-8k](https://huggingface.co/datasets/ceadar-ie/AIVision360-8k)

## Dataset Utilized: AIVision360-8k

Drawing strength from the AIVision360-8k dataset, a curated collection hailing from "ainewshub.ie", this model is tailor-made for technology media and journalism. Offering structured interactions related to AI news, it captures the essence of the latest AI trends and evolutions. For a deeper dive into the dataset visit: [AIVision360-8k](https://huggingface.co/datasets/ceadar-ie/AIVision360-8k)

### Model Specification

- **Developed by:** CeADAR Connect Group
- **Model type:** Large Language Model
- **Language(s):** en
- **Finetuned from model:** Llama2-7B

## Key Features and Functionalities

### Domain Specialization
The Llama2-7B-AIVision360 model is specialized in AI news, serving as a resource for AI researchers, enthusiasts, and media experts.
### Model API Accessibility
Offers a straightforward Python integration for generating AI news insights.
### Performance Optimisation
Efficient performance across both CPU and GPU platforms.
### Data Representation
Utilises a comprehensive AI news dataset, enabling content generation to professional journalism standards.

## Model Usage

Experience the capabilities of the Llama2-7B-AIVision360 model through a well-structured Python interface. To kick-start your exploration, follow the steps and snippets given below:

## Prerequisites
### 1. Ensure required packages are available

```python
import torch
import transformers
from typing import Any, Dict
from transformers import PreTrainedTokenizerFast, AutoTokenizer, 
AutoModelForCausalLM
from transformers import (
    AutoModelForCausalLM,
    AutoTokenizer,
    BitsAndBytesConfig,
    HfArgumentParser,
    TrainingArguments,
    pipeline,
    logging,
)
import time
```

### 2. Initiate the model and tokenizer

```python
model_name = "ceadar-ie/Llama2-7B-AIVision360"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", 
torch_dtype=torch.float16, trust_remote_code=True)
```

### 3. Create a function for generating text

```python
def generate_text(input_text):
    num_words_input = len(input_text.split())

    start_time = time.time()
    
    pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=500,temperature=1, top_k=10, top_p=0.1, repetition_penalty = 1.15)
    prompt = f" [INST] {input_text} [/INST]"
    result = pipe(prompt)
    generated_text = result[0]['generated_text'].replace(prompt, "").strip()

    end_time = time.time()
    time_taken = end_time - start_time

    num_words_generated = len(generated_text.split())

    print("Generated Output:")
    print(generated_text)
    print('=' * 60 )
    print("\nNumber of Words in Input Text:", num_words_input)
    print("Number of Words in Generated Output:", num_words_generated)
    print("Time Taken to Generate Output: {:.2f} seconds".format(time_taken))
```

## Example Evaluation and Use

### Example Prompt 1: 
Concisely list any recent controversies or debates in the AI community.

### Generated Output: 
The text discusses the latest news and developments in the AI industry, 
specifically highlighting controversies and debates that have been ongoing in the community. 
Recent controversies or debates in the AI community include:
- Debate over whether AI-generated art is art.
- Controversy over a study claiming that AIs can defeat humans at chess.
- Disagreement among experts about the risk of extinction from AIs.
- Concerns about the use of AI to manipulate images of children.
- Proposals for new rules governing generative AI.
- Criticism of companies using AI-powered customer service technology without proper disclosure.
- Worries about the potential misuse of large language models like GPT-4.


### Example Prompt 2: 
List new regulations or guidelines that have been introduced globally concerning AI ethics and bias mitigation.

### Generated Output: 
There has been an increased focus on regulating artificial intelligence (AI) 
globally due to concerns about ethics, bias, and the potential for disinformation. New regulations
or guidelines include:
- European Commission's proposal for a law to ensure that AI systems are not biased against people with disabilities, race, gender, age, or religion.
- OECD's recommendation on non-discrimination in AI decision-making.
- ILO's updated recommendations on equal pay and other forms of discrimination.
- Adoption of the Global Factorial Code by the UK government.
- Benchmarks by the World Benchmark Foundation to measure the respect of human rights in AI products.
- Tool by the Human Rights Foundation to assess respect of individual freedoms in generative AI applications.


### Example Prompt 3: 
What are the current market trends in the AI industry?

### Generated Output: 
The AI industry is rapidly evolving with notable trends such as:
- Increased Adoption of Cloud-based AI Services.
- Growing Focus on Explainability and Interpretability.
- Integration of AI with Other Technologies.
- Increased Focus on Ethics and Fairness.
- Growing Demand for AI Talent.
- Increased Focus on Cybersecurity


### Example Prompt 4:  
Which sectors or industries are seeing the most rapid AI adoption right now?

### Generated Output: 
AI adoption is evident across various sectors, including:
- Healthcare: AI in analyzing medical images, diagnosing diseases, and chatbots for health advice.
- Finance: Detecting fraud, analyzing financial data, and AI-powered financial advice.
- Retail: Personalizing customer experiences, optimizing inventory, and AI chatbots for product recommendations.
- Manufacturing: Optimizing production, predicting maintenance, and monitoring industrial equipment.
- Transportation: Developing autonomous vehicles, improving traffic flow, and optimizing logistics.
- Energy: Optimizing energy consumption, predicting demand, and enhancing renewable energy efficiency.
- Agriculture: Optimizing yields, predicting weather, and monitoring agricultural equipment.
- Education: Personalizing learning, grading assignments, and developing adaptive learning systems.
- Security: Detecting cyber attacks, analyzing surveillance footage, and improving emergency responses.

## Training Details

### Training Hyperparameters
- per_device_train_batch_size = 10
- gradient_accumulation_steps = 4
- optim = "paged_adamw_32bit"
- warmup_steps = 100
- learning_rate = 2e-4
- max_grad_norm = 0.3
- warmup_ratio = 0.03

## Model Limitations
Potential Biases: With its fine-tuning centered on AI news sources, inherent biases from these sources may reflect in the model's outputs.

## Licensing
The Llama2-7B-AIVision360 model, developed in collaboration with CeADAR Connect Group, combines the licensing frameworks of both Llama2 and AIVision360. Under Meta's terms, users are granted a non-exclusive, worldwide, non-transferable, royalty-free limited license for the use and modification of Llama Materials, inclusive of the Llama2 model and its associated documentation. When redistributing, the provided Agreement and a specific attribution notice must be included. In alignment with the AIVision360 dataset's licensing, the model is also distributed under the Apache 2.0 open-source license, promoting its use and modification within the AI community, while ensuring content reliability sourced from established AI news publishers.

## Out-of-Scope Use
Llama2-7B-AIVision360 is specifically tailored for AI news discussions. It is not optimized for:

- General, non-AI-related conversations.
- Domain-specific tasks outside AI news.
- Direct interfacing with physical devices or applications.


## Bias, Risks, and Limitations
- Dataset Biases: The AIVision360-8k dataset may contain inherent biases that influence the model's outputs.
- Over-reliance: The model is an aid, not a replacement for human expertise. Decisions should be made with careful consideration.
- Content Understanding: The model lacks human-like understanding and cannot judge the veracity of news.
- Language Limitations: The model's primary language is English. Performance may decrease with other languages.
- Knowledge Cut-off: The model may not be aware of events or trends post its last training update.

## Citation:
```
@misc {ceadar_2023,
	author       = { {CeADAR} },
	title        = { Llama2-7B-AIVision360 (Revision e349e9a) },
	year         = 2023,
	url          = { https://huggingface.co/ceadar-ie/Llama2-7B-AIVision360 },
	doi          = { 10.57967/hf/1069 },
	publisher    = { Hugging Face }
}
```
## Contact:
For any further inquiries or feedback concerning Llama2-7B-AIVision360, please forward your communications to ahtsham.zafar@ucd.ie