mirror of
https://github.com/acon96/home-llm.git
synced 2026-01-09 13:48:05 -05:00
46
.github/workflows/create-release.yml
vendored
46
.github/workflows/create-release.yml
vendored
@@ -18,26 +18,50 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
home_assistant_version: ["2023.12.4", "2024.2.1"]
|
||||
arch: [aarch64, armhf, amd64, i386]
|
||||
suffix: [""]
|
||||
include:
|
||||
# ARM variants
|
||||
- home_assistant_version: "2023.12.4"
|
||||
arch: "aarch64"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "aarch64"
|
||||
- home_assistant_version: "2023.12.4"
|
||||
arch: "armhf"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "armhf"
|
||||
|
||||
# Base x86
|
||||
- home_assistant_version: "2024.2.1"
|
||||
suffix: "-noavx"
|
||||
arch: "amd64"
|
||||
extra_defines: "-DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
- home_assistant_version: "2023.12.4"
|
||||
arch: "amd64"
|
||||
suffix: "-noavx"
|
||||
extra_defines: "-DLLAMA_NATIVE=OFF -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "amd64"
|
||||
suffix: "-avx512"
|
||||
extra_defines: "-DLLAMA_NATIVE=OFF -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_AVX512=ON"
|
||||
extra_defines: "-DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "i386"
|
||||
suffix: "-noavx"
|
||||
extra_defines: "-DLLAMA_NATIVE=OFF -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
extra_defines: "-DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
- home_assistant_version: "2023.12.4"
|
||||
arch: "i386"
|
||||
suffix: "-noavx"
|
||||
extra_defines: "-DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF"
|
||||
|
||||
# AVX2 and AVX512
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "amd64"
|
||||
extra_defines: "-DLLAMA_AVX=ON -DLLAMA_AVX2=ON -DLLAMA_FMA=ON -DLLAMA_F16C=ON"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "amd64"
|
||||
suffix: "-avx512"
|
||||
extra_defines: "-DLLAMA_AVX512=ON -DLLAMA_FMA=ON -DLLAMA_F16C=ON"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "i386"
|
||||
extra_defines: "-DLLAMA_AVX=ON -DLLAMA_AVX2=ON -DLLAMA_FMA=ON -DLLAMA_F16C=ON"
|
||||
- home_assistant_version: "2024.2.1"
|
||||
arch: "i386"
|
||||
suffix: "-avx512"
|
||||
extra_defines: "-DLLAMA_NATIVE=OFF -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_AVX512=ON"
|
||||
extra_defines: "-DLLAMA_AVX512=ON -DLLAMA_FMA=ON -DLLAMA_F16C=ON"
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -75,7 +99,7 @@ jobs:
|
||||
git clone --quiet --recurse-submodules https://github.com/abetlen/llama-cpp-python --branch "v${{ env.EMBEDDED_LLAMA_CPP_PYTHON_VERSION }}"
|
||||
cd llama-cpp-python
|
||||
|
||||
export CMAKE_ARGS="-DLLAVA_BUILD=OFF ${{ matrix.extra_defines }}"
|
||||
export CMAKE_ARGS="-DLLAVA_BUILD=OFF -DLLAMA_NATIVE=OFF ${{ matrix.extra_defines }}"
|
||||
python3 -m build --wheel
|
||||
|
||||
ls -la ./dist/
|
||||
|
||||
@@ -126,7 +126,8 @@ In order to facilitate running the project entirely on the system where Home Ass
|
||||
## Version History
|
||||
| Version | Description |
|
||||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| v0.2.16 | Fix for missing huggingface_hub package preventing startup |
|
||||
| v0.2.17 | Disable native llama.cpp wheel optimizations, add Command R prompt format |
|
||||
| v0.2.16 | Fix for missing huggingface_hub package preventing startup |
|
||||
| v0.2.15 | Fix startup error when using llama.cpp backend and add flash attention to llama.cpp backend |
|
||||
| v0.2.14 | Fix llama.cpp wheels + AVX detection |
|
||||
| v0.2.13 | Add support for Llama 3, build llama.cpp wheels that are compatible with non-AVX systems, fix an error with exposing script entities, fix multiple small Ollama backend issues, and add basic multi-language support |
|
||||
|
||||
@@ -63,6 +63,7 @@ CONF_ALLOWED_SERVICE_CALL_ARGUMENTS = "allowed_service_call_arguments"
|
||||
DEFAULT_ALLOWED_SERVICE_CALL_ARGUMENTS = ["rgb_color", "brightness", "temperature", "humidity", "fan_mode", "hvac_mode", "preset_mode", "item", "duration"]
|
||||
CONF_PROMPT_TEMPLATE = "prompt_template"
|
||||
PROMPT_TEMPLATE_CHATML = "chatml"
|
||||
PROMPT_TEMPLATE_COMMAND_R = "command-r"
|
||||
PROMPT_TEMPLATE_ALPACA = "alpaca"
|
||||
PROMPT_TEMPLATE_VICUNA = "vicuna"
|
||||
PROMPT_TEMPLATE_MISTRAL = "mistral"
|
||||
@@ -79,6 +80,12 @@ PROMPT_TEMPLATE_DESCRIPTIONS = {
|
||||
"assistant": { "prefix": "<|im_start|>assistant\n", "suffix": "<|im_end|>" },
|
||||
"generation_prompt": "<|im_start|>assistant"
|
||||
},
|
||||
PROMPT_TEMPLATE_COMMAND_R: {
|
||||
"system": { "prefix": "<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>", "suffix": "<|END_OF_TURN_TOKEN|>" },
|
||||
"user": { "prefix": "<|START_OF_TURN_TOKEN|><|USER_TOKEN|>", "suffix": "<|END_OF_TURN_TOKEN|>" },
|
||||
"assistant": { "prefix": "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>", "suffix": "<|END_OF_TURN_TOKEN|>" },
|
||||
"generation_prompt": "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>"
|
||||
},
|
||||
PROMPT_TEMPLATE_ALPACA: {
|
||||
"system": { "prefix": "", "suffix": "\n" },
|
||||
"user": { "prefix": "### Instruction:\n", "suffix": "\n" },
|
||||
@@ -280,9 +287,14 @@ OPTIONS_OVERRIDES = {
|
||||
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_ZEPHYR,
|
||||
},
|
||||
"phi-3": {
|
||||
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_ZEPHYR3
|
||||
CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_EXTRAS,
|
||||
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_ZEPHYR3,
|
||||
},
|
||||
"command-r": {
|
||||
CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_EXTRAS,
|
||||
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_COMMAND_R,
|
||||
}
|
||||
}
|
||||
|
||||
INTEGRATION_VERSION = "0.2.16"
|
||||
EMBEDDED_LLAMA_CPP_PYTHON_VERSION = "0.2.69"
|
||||
INTEGRATION_VERSION = "0.2.17"
|
||||
EMBEDDED_LLAMA_CPP_PYTHON_VERSION = "0.2.70"
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"domain": "llama_conversation",
|
||||
"name": "LLaMA Conversation",
|
||||
"version": "0.2.16",
|
||||
"version": "0.2.17",
|
||||
"codeowners": ["@acon96"],
|
||||
"config_flow": true,
|
||||
"dependencies": ["conversation"],
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
"zephyr2": "Zephyr ('</s>')",
|
||||
"zephyr3": "Zephyr (<|end|>)",
|
||||
"llama3": "Llama 3",
|
||||
"command-r": "Command R",
|
||||
"no_prompt_template": "None"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -114,13 +114,21 @@ def install_llama_cpp_python(config_dir: str):
|
||||
|
||||
instruction_extensions_suffix = ""
|
||||
if platform_suffix == "amd64" or platform_suffix == "i386":
|
||||
instruction_extensions_suffix = "-noavx"
|
||||
|
||||
try:
|
||||
with open("/proc/cpuinfo") as f:
|
||||
cpu_features = [ line for line in f.readlines() if line.startswith("Features") or line.startswith("flags")][0]
|
||||
if "avx512f" in cpu_features and "avx512bw" in cpu_features:
|
||||
|
||||
_LOGGER.debug(cpu_features)
|
||||
if " avx512f " in cpu_features and " avx512bw " in cpu_features:
|
||||
instruction_extensions_suffix = "-avx512"
|
||||
elif "avx2" not in cpu_features or "avx" not in cpu_features or "f16c" not in cpu_features or "fma" not in cpu_features or not ("sse3" in cpu_features or "ssse3" in cpu_features):
|
||||
instruction_extensions_suffix = "-noavx"
|
||||
elif " avx2 " in cpu_features and \
|
||||
" avx " in cpu_features and \
|
||||
" f16c " in cpu_features and \
|
||||
" fma " in cpu_features and \
|
||||
(" sse3 " in cpu_features or " ssse3 " in cpu_features):
|
||||
instruction_extensions_suffix = ""
|
||||
except Exception as ex:
|
||||
_LOGGER.debug(f"Couldn't detect CPU features: {ex}")
|
||||
# default to the noavx build to avoid crashing home assistant
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"""Original script by @BramNH on GitHub"""
|
||||
import argparse
|
||||
import csv
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
|
||||
from deep_translator import GoogleTranslator
|
||||
from deep_translator import GoogleTranslator, DeeplTranslator
|
||||
from deep_translator.base import BaseTranslator
|
||||
from deep_translator.exceptions import TooManyRequests
|
||||
from tqdm import tqdm
|
||||
from transformers import pipeline
|
||||
import langcodes
|
||||
|
||||
SUPPORTED_DEVICES = [
|
||||
"light",
|
||||
@@ -32,20 +33,22 @@ class Seq2SeqTranslator(BaseTranslator):
|
||||
def __init__(self, model_name: str, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
from transformers import pipeline
|
||||
|
||||
self.translator = pipeline("translation", model=model_name, tokenizer=model_name, device=0)
|
||||
|
||||
def translate(self, text: str, **kwargs):
|
||||
return self.translator(text)[0]["translation_text"]
|
||||
|
||||
class DatasetTranslator:
|
||||
translator: Seq2SeqTranslator
|
||||
translator: BaseTranslator
|
||||
source_language: str
|
||||
target_language: str
|
||||
|
||||
def __init__(self, source_language, target_language, model_name):
|
||||
def __init__(self, source_language, target_language, translator):
|
||||
self.source_language = source_language
|
||||
self.target_language = target_language
|
||||
self.translator = Seq2SeqTranslator(model_name=model_name)
|
||||
self.translator = translator
|
||||
|
||||
def translate_all_piles(self):
|
||||
os.makedirs(f"./piles/{self.target_language}", exist_ok=True)
|
||||
@@ -334,7 +337,32 @@ class DatasetTranslator:
|
||||
f.writelines(pile_of_todo_items_target)
|
||||
|
||||
|
||||
# TODO: cmd line args
|
||||
DatasetTranslator("english", "german", "Helsinki-NLP/opus-mt-en-de").translate_all_piles()
|
||||
# DatasetTranslator("english", "spanish", "Helsinki-NLP/opus-mt-en-es").translate_all_piles()
|
||||
# DatasetTranslator("english", "french", "Helsinki-NLP/opus-mt-en-fr").translate_all_piles()
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("destination_language", help="Destination language for translation")
|
||||
parser.add_argument("--source_language", default="english", help="Source language for translation (default: english)")
|
||||
parser.add_argument("--translator_type", choices=["google", "transformers", "deepl"], required=True, help="Translator type (choose from: google, transformers, deepl)")
|
||||
parser.add_argument("--model_name", help="Model name (optional)")
|
||||
parser.add_argument("--api_key", help="API key (optional)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
source_code = langcodes.find(args.source_language).language
|
||||
dest_code = langcodes.find(args.destination_language).language
|
||||
|
||||
if args.translator_type == "google":
|
||||
translator = GoogleTranslator(source=source_code, target=dest_code)
|
||||
elif args.translator_type == "transformers":
|
||||
if not args.model_name:
|
||||
print("No model name was provided!")
|
||||
parser.print_usage()
|
||||
exit(-1)
|
||||
translator = Seq2SeqTranslator(model_name=args.model_name)
|
||||
elif args.translator_type == "deepl":
|
||||
if not args.api_key and os.getenv():
|
||||
print("No api key was provided!")
|
||||
parser.print_usage()
|
||||
exit(-1)
|
||||
translator = DeeplTranslator(source=source_code, target=dest_code, api_key=args.api_key)
|
||||
|
||||
DatasetTranslator(args.source_language, args.destination_language, translator).translate_all_piles()
|
||||
@@ -9,6 +9,7 @@ pandas
|
||||
# flash-attn
|
||||
sentencepiece
|
||||
deep-translator
|
||||
langcodes
|
||||
|
||||
homeassistant
|
||||
hassil
|
||||
|
||||
Reference in New Issue
Block a user