llama.cpp serverを使って、入力文字列を翻訳するスクリプト。
使用方法
python LLM_Translator.py
[-h]
[-i 入力ファイルパス] [-o 出力ファイルパス] [-p プロンプトファイルパス] [-d 辞書ファイルパス]
[-u llama.cpp serverのURL] [--quiet] [--no-outfile] [--include-input] [--min-context-count 最小保持ターン数]
llama.cpp serverを使って、入力文字列を翻訳するスクリプト。
使用方法
python LLM_Translator.py
[-h]
[-i 入力ファイルパス] [-o 出力ファイルパス] [-p プロンプトファイルパス] [-d 辞書ファイルパス]
[-u llama.cpp serverのURL] [--quiet] [--no-outfile] [--include-input] [--min-context-count 最小保持ターン数]
# Apache License 2.0 | |
# 使用法は gist のコメントを見てください | |
import argparse | |
from typing import List, Optional, Union, Iterator | |
import llama_cpp | |
from llama_cpp.llama_chat_format import _convert_completion_to_chat, register_chat_completion_handler | |
import llama_cpp.llama_types as llama_types | |
from llama_cpp.llama import LogitsProcessorList, LlamaGrammar | |
from llama_cpp import Llama, llama_chat_format |
# Reference #1: https://note.com/npaka/n/nc55e44e407ff | |
# Reference #2: https://huggingface.co/blog/gemma-peft | |
# Licence: MIT | |
from peft import LoraConfig | |
lora_config = LoraConfig( | |
r=8, | |
target_modules=["q_proj", "o_proj", "k_proj", "v_proj", "gate_proj", "up_proj", "down_proj"], | |
task_type="CAUSAL_LM", |
import gzip | |
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
""" | |
文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
Parameters: | |
query (str): 検索クエリとして使用する文字列. | |
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |
# Program: VTSTech-GPT.py 2025-01-28 1:02:59 PM | |
# Description: Python script that generates text with Cerebras GPT pretrained and Corianas finetuned models | |
# Author: Written by Veritas//VTSTech ([email protected]) | |
# GitHub: https://github.com/VTSTech | |
# Homepage: www.VTS-Tech.org | |
# Dependencies: transformers, colorama, Flask | |
# pip install transformers colorama flask | |
# Models are stored at C:\Users\%username%\.cache\huggingface\hub | |
import argparse | |
import time |
{ | |
"schema_version": "v1", | |
"name_for_model": "twilio", | |
"name_for_human": "Twilio Plugin", | |
"description_for_model": "Plugin for integrating the Twilio API to send SMS messages and make phone calls. Use it whenever a user wants to send a text message or make a call using their Twilio account.", | |
"description_for_human": "Send text messages and make phone calls with Twilio.", | |
"auth": { | |
"type": "user_http", | |
"authorization_type": "basic" | |
}, |
# STEP 1: Load | |
# Load documents using LangChain's DocumentLoaders | |
# This is from https://langchain.readthedocs.io/en/latest/modules/document_loaders/examples/csv.html | |
from langchain.document_loaders.csv_loader import CSVLoader | |
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv') | |
data = loader.load() |