asiansoul's picture
Update README.md
a0817a1 verified
|
raw
history blame
12 kB
metadata
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

Smart-Llama-3-Ko-8-B-256k-Po-SE

SmartLlama-3-Ko-8B-256k-PoSE 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:

πŸ–‹οΈ 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:

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

Summary of Steve Jobs Text File

Steve Jobs Text File Summary

Summary of Jay Park on Wikipedia

Jay Park Wikipedia Summary

Test Source From

λ°•μž¬λ²” - wikipedia - EN

[λ°•μž¬λ²” - wikipedia - KR](https://ko.wikipedia.org/wiki/%EB%B0%95%EC%9E%AC%EB%B2%94

Britney Spears - wikipedia - EN

[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?