File size: 12,002 Bytes
6bde718 013b69f 6bde718 16cd86b 6bde718 16cd86b 6bde718 16cd86b 6bde718 16cd86b 994bf33 d9130e5 3559e8d bec11c7 3559e8d 58000b1 d9130e5 58000b1 d9130e5 58000b1 d9130e5 58000b1 d9130e5 58000b1 d9130e5 58000b1 d9130e5 58000b1 d9130e5 8348df6 16cd86b 6bde718 9447cb0 47173a2 6bde718 2092913 051503e bec11c7 f6ed970 571ea1b 051503e 571ea1b f6ed970 571ea1b ca95c4e b96a77d dc17918 e754b06 6a4d52c dc17918 6a4d52c dc17918 7876f42 bec11c7 ed8f868 f5973df 7876f42 f5973df a0817a1 bec11c7 f5973df 4645ed5 a0817a1 f5973df bec11c7 a0817a1 |
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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
---
base_model:
- winglian/llama-3-8b-256k-PoSE
- Locutusque/Llama-3-Orca-1.0-8B
- NousResearch/Meta-Llama-3-8B
- abacusai/Llama-3-Smaug-8B
- beomi/Llama-3-Open-Ko-8B-Instruct-preview
- NousResearch/Meta-Llama-3-8B-Instruct
library_name: transformers
tags:
- mergekit
- merge
---
# π°π· SmartLlama-3-Ko-8B-256k-PoSE
<a href="https://ibb.co/rs8DhB8"><img src="https://i.ibb.co/8cv1wyv/Smart-Llama-3-Ko-8-B-256k-Po-SE.png" alt="Smart-Llama-3-Ko-8-B-256k-Po-SE" border="0"></a>
SmartLlama-3-Ko-8B-256k-[PoSE](https://huggingface.co/papers/2309.10400) is an advanced AI model that integrates the capabilities of several advanced language models, designed to excel in a variety of tasks ranging from technical problem-solving to multilingual communication, especially with its extended context length of 256k tokens. This model is uniquely positioned to handle larger and more complex datasets and longer conversational contexts, making it ideal for deep learning applications requiring extensive text understanding and generation.
## π Merge Details
### Component Models and Contributions
- **NousResearch/Meta-Llama-3-8B and Meta-Llama-3-8B-Instruct**: These models provide a solid foundation for general language understanding and instruction-following capabilities.
- **winglian/llama-3-8b-256k-PoSE**: Utilizes Positional Skip-wise Training (PoSE) to extend Llama's context length to 256k, significantly improving the model's ability to handle extensive texts and complex instructions, enhancing performance in tasks requiring long-duration focus and memory.
- **Locutusque/Llama-3-Orca-1.0-8B**: Specializes in mathematical, coding, and writing tasks, bringing precision to technical and creative outputs.
- **abacusai/Llama-3-Smaug-8B**: Improves the model's performance in real-world, multi-turn conversations, which is crucial for applications in customer service and interactive learning environments.
- **beomi/Llama-3-Open-Ko-8B-Instruct-preview**: Focuses on improving understanding and generation of Korean, offering robust solutions for bilingual or multilingual applications targeting Korean-speaking audiences.
## πΌοΈ Key Features
- **Extended Context Length**: Utilizes the PoSE (Positional Encoding) technique to handle up to 256,000 tokens, making it ideal for analyzing large volumes of text such as books, comprehensive reports, and lengthy communications.
- **Multilingual Support**: While primarily focused on Korean language processing, this model also provides robust support for multiple languages, enhancing its utility in global applications.
- **Advanced Integration of Models**: Combines strengths from various models including NousResearch's Meta-Llama-3-8B, the instruction-following capabilities of Llama-3-Open-Ko-8B-Instruct-preview, and specialized capabilities from models like Llama-3-Smaug-8B for nuanced dialogues and Orca-1.0-8B for technical precision.
## π¨ Models Merged
The following models were included in the merge:
- **winglian/llama-3-8b-256k-PoSE**: [Extends the context handling capability](https://huggingface.co/winglian/llama-3-8b-256k-PoSE). This model uses Positional Skip-wise Training (PoSE) to enhance the handling of extended context lengths, up to 256k tokens.
- **Locutusque/Llama-3-Orca-1.0-8B**: [Enhances abilities in handling technical content](https://huggingface.co/Locutusque/Llama-3-Orca-1.0-8B). Specialized in computational, scientific, and technical tasks, improving the model's ability to process complex academic and technical language.
- **abacusai/Llama-3-Smaug-8B**: [Improves multi-turn conversational abilities](https://huggingface.co/abacusai/Llama-3-Smaug-8B). Boosts performance in engaging in lengthy, context-aware dialogues necessary for effective customer service and interactive learning.
- **beomi/Llama-3-Open-Ko-8B-Instruct-preview**: [Provides enhanced capabilities for Korean language processing](https://huggingface.co/beomi/Llama-3-Open-Ko-8B-Instruct-preview). This model is fine-tuned to understand and generate Korean, making it ideal for applications targeting Korean-speaking users.
- **NousResearch/Meta-Llama-3-8B-Instruct**: [Offers advanced instruction-following capabilities](https://huggingface.co/NousResearch/Meta-Llama-3-8B-Instruct). It is optimized to follow complex instructions, enhancing the model's utility in task-oriented dialogues and applications that require a high level of understanding and execution of user commands.
### ποΈ Merge Method
- **DARE TIES**: This method was employed to ensure that each component model contributes effectively to the merged model, maintaining a high level of performance across diverse applications. NousResearch/Meta-Llama-3-8B served as the base model for this integration, providing a stable and powerful framework for the other models to build upon.
## π» Ollama
```
ollama create smartllama-3-Ko-8b-256k-pose -f ./Modelfile_Q5_K_M
```
[Modelfile_Q5_K_M]
```
FROM smartllama-3-ko-8b-256k-pose-Q5_K_M.gguf
TEMPLATE """
{{- if .System }}
system
<s>{{ .System }}</s>
{{- end }}
user
<s>Human:
{{ .Prompt }}</s>
assistant
<s>Assistant:
"""
SYSTEM """
μΉμ ν μ±λ΄μΌλ‘μ μλλ°©μ μμ²μ μ΅λν μμΈνκ³ μΉμ νκ² λ΅νμ. κΈΈμ΄μ μκ΄μμ΄ λͺ¨λ λλ΅μ νκ΅μ΄(Korean)μΌλ‘ λλ΅ν΄μ€.
"""
PARAMETER temperature 0.7
PARAMETER num_predict 3000
PARAMETER num_ctx 256000
PARAMETER stop "<s>"
PARAMETER stop "</s>"
```
## π» Ollama Python Summarizing Test Code
install all of these libraries
```
pip install requests beautifulsoup4 PyPDF2 langchain-community langchain
```
pose_test.py
```
import sys
import os
import requests
from bs4 import BeautifulSoup
import PyPDF2
from langchain_community.chat_models import ChatOllama
from langchain.schema import AIMessage, HumanMessage, SystemMessage
def clean_output(text):
text = text.replace("</s>", "").strip()
return text
def invoke_model(text):
messages = [
SystemMessage(content='You are an expert copywriter with expertise in summarizing documents.'),
HumanMessage(content=f'Please provide a short and concise summary of the following text:\nTEXT: {text}')
]
try:
llm = ChatOllama(model="pose:latest")
summary_output = llm.invoke(messages)
if isinstance(summary_output, AIMessage):
cleaned_content = clean_output(summary_output.content)
return cleaned_content
else:
return "Unexpected data type for model output."
except Exception as e:
print(f"An error occurred while processing the model output: {str(e)}")
return None
def fetch_text_from_url(url):
try:
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
content = soup.find('div', {'id': 'bodyContent'})
paragraphs = content.find_all('p')
text_content = ' '.join(p.text for p in paragraphs)
return text_content
except requests.RequestException as e:
print(f"Failed to fetch data from URL: {str(e)}")
return None
def read_text_file(file_path):
with open(file_path, "r", encoding="utf-8") as file:
return file.read()
def read_pdf(file_path):
with open(file_path, "rb") as file:
reader = PyPDF2.PdfReader(file)
text_content = ""
for page in reader.pages:
extracted_text = page.extract_text()
if extracted_text:
text_content += extracted_text + "\n"
return text_content
def summarize_content(source):
if source.startswith(('http://', 'https://')):
text_content = fetch_text_from_url(source)
else:
_, file_extension = os.path.splitext(source)
if file_extension.lower() == '.pdf':
text_content = read_pdf(source)
elif file_extension.lower() in ['.txt', '.text']:
text_content = read_text_file(source)
else:
print("Unsupported file type")
return
if text_content:
summary = invoke_model(text_content)
print("Summary of the document:")
print(summary)
else:
print("No text found or unable to extract text from source.")
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python script.py <file_path_or_url>")
else:
source = sys.argv[1]
summarize_content(source)
```
run txt file (assume txt is a.txt)
```
python pose_test.py a.txt
```
run url (assume txt is url)
```
python pose_test.py url
```
You can find both test results below on the section : Test Result
### ποΈ Configuration
The YAML configuration for this model:
```yaml
models:
- model: NousResearch/Meta-Llama-3-8B
# Base model providing a general foundation without specific parameters
- model: NousResearch/Meta-Llama-3-8B-Instruct
parameters:
density: 0.60
weight: 0.25
- model: winglian/llama-3-8b-256k-PoSE
parameters:
density: 0.60
weight: 0.20
- model: Locutusque/Llama-3-Orca-1.0-8B
parameters:
density: 0.55
weight: 0.15
- model: abacusai/Llama-3-Smaug-8B
parameters:
density: 0.55
weight: 0.15
- model: beomi/Llama-3-Open-Ko-8B-Instruct-preview
parameters:
density: 0.55
weight: 0.30
merge_method: dare_ties
base_model: NousResearch/Meta-Llama-3-8B
parameters:
int8_mask: true
dtype: bfloat16
```
Test OS Condition
```
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro18,2
Chip: Apple M1 Max
Total Number of Cores: 10 (8 performance and 2 efficiency)
Memory: 64 GB
System Firmware Version: 10151.101.3
OS Loader Version: 10151.101.3
```
### π Test Result
**SmartLlama-3-Ko-8B-256k-PoSE Summary Ability**
consideration
Long sentences seemed to summarize well, but I observed that answers came in English. And when I asked for it to be translated into Korean, I confirmed that it was translated well. The summary seems to work well, but you can take into account the fact that there are times when it cannot be summarized directly in Korean.
## Summary of Britney Spears on Wikipedia
[![Britney Spears Singer Wikipedia Summary](https://i.ibb.co/2600HbV/Screenshot-2024-05-02-at-11-52-58-AM.png)](https://ibb.co/7zxxL9M)
## Summary of Steve Jobs Text File
[![Steve Jobs Text File Summary](https://i.ibb.co/10tRCrj/Screenshot-2024-05-02-at-11-54-50-AM.png)](https://ibb.co/9pkyxbS)
## Summary of Jay Park on Wikipedia
[![Jay Park Wikipedia Summary](https://i.ibb.co/nmkpbCt/Screenshot-2024-05-02-at-1-33-30-PM.png)](https://ibb.co/g9gY3Vh)
**Test Source From**
[λ°μ¬λ² - wikipedia - EN](https://en.wikipedia.org/wiki/Jay_Park)
[λ°μ¬λ² - wikipedia - KR](https://ko.wikipedia.org/wiki/%EB%B0%95%EC%9E%AC%EB%B2%94
[Britney Spears - wikipedia - EN](https://en.wikipedia.org/wiki/Britney_Spears)
[Community member : Mr Han' steve jobs txt file]
### βοΈ Test Issue
2024-05-02
```
If you use load_summarize_chain(), there will be repetition. -> community member Mr.Han issue
Is it a merge issue? He thinks the merge target may be the issue.
chain = load_summarize_chain(
llm,
chain_type='stuff',
prompt=prompt,
verbose=False
)
output_summary = chain.invoke(docs)
-> investigating for me how to solve.....
```
```
Mr.Han is investgating the symptoms
Your OS is using REDHAT. Even if I run the code using the LLAMA3 model provided by ollama, there is an error.
I wonder if I should wait a little longer for Red Hat...
<|eot_id|><|start_header_id|>assistant<|end_header_id|>, ... omitted
Ha ha, thanks for the chat! You too have a great day and happy summarizing if you need it again soon!<|eot_id|><|start_header_id|>assistant<|end_header_id|>
It's not a merge problem... I think it's a fundamental problem that doesn't fit the OS environment... so I'm sharing it with you. Is there anyone who has the same problem as me in redhat?
```
|