当前位置: 首页 > news >正文

淘客做网站网络优化工程师需要学什么

淘客做网站,网络优化工程师需要学什么,微信小程序开发团队,wechat wordpress视频中所出现的代码 Tavily SearchRAG 微调Llama3实现在线搜索引擎和RAG检索增强生成功能!打造自己的perplexity和GPTs!用PDF实现本地知识库_哔哩哔哩_bilibili 一.准备工作 1.安装环境 conda create --name unsloth_env python3.10 conda activate …

视频中所出现的代码 Tavily Search+RAG

微调Llama3实现在线搜索引擎和RAG检索增强生成功能!打造自己的perplexity和GPTs!用PDF实现本地知识库_哔哩哔哩_bilibili

一.准备工作

1.安装环境

conda create --name unsloth_env python=3.10
conda activate unsloth_envconda install pytorch-cuda=12.1 pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformerspip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"pip install --no-deps trl peft accelerate bitsandbytes

 2.微调代码(要先登录一下)

huggingface-cli login

点击提示的网页获取token(注意要选择可写的)


#dataset https://huggingface.co/datasets/shibing624/alpaca-zh/viewerfrom unsloth import FastLanguageModel
import torchfrom trl import SFTTrainer
from transformers import TrainingArgumentsmax_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.# 4bit pre quantized models we support for 4x faster downloading + no OOMs.
fourbit_models = ["unsloth/mistral-7b-bnb-4bit","unsloth/mistral-7b-instruct-v0.2-bnb-4bit","unsloth/llama-2-7b-bnb-4bit","unsloth/gemma-7b-bnb-4bit","unsloth/gemma-7b-it-bnb-4bit", # Instruct version of Gemma 7b"unsloth/gemma-2b-bnb-4bit","unsloth/gemma-2b-it-bnb-4bit", # Instruct version of Gemma 2b"unsloth/llama-3-8b-bnb-4bit", # [NEW] 15 Trillion token Llama-3
] # More models at https://huggingface.co/unslothmodel, tokenizer = FastLanguageModel.from_pretrained(model_name = "unsloth/llama-3-8b-bnb-4bit",max_seq_length = max_seq_length,dtype = dtype,load_in_4bit = load_in_4bit,# token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
)model = FastLanguageModel.get_peft_model(model,r = 16, # Choose any number > 0 ! Suggested 8, 16, 32, 64, 128target_modules = ["q_proj", "k_proj", "v_proj", "o_proj","gate_proj", "up_proj", "down_proj",],lora_alpha = 16,lora_dropout = 0, # Supports any, but = 0 is optimizedbias = "none",    # Supports any, but = "none" is optimized# [NEW] "unsloth" uses 30% less VRAM, fits 2x larger batch sizes!use_gradient_checkpointing = "unsloth", # True or "unsloth" for very long contextrandom_state = 3407,use_rslora = False,  # We support rank stabilized LoRAloftq_config = None, # And LoftQ
)alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.### Instruction:
{}### Input:
{}### Response:
{}"""EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN
def formatting_prompts_func(examples):instructions = examples["instruction"]inputs       = examples["input"]outputs      = examples["output"]texts = []for instruction, input, output in zip(instructions, inputs, outputs):# Must add EOS_TOKEN, otherwise your generation will go on forever!text = alpaca_prompt.format(instruction, input, output) + EOS_TOKENtexts.append(text)return { "text" : texts, }
passfrom datasets import load_dataset#file_path = "/home/Ubuntu/alpaca_gpt4_data_zh.json"#dataset = load_dataset("json", data_files={"train": file_path}, split="train")dataset = load_dataset("yahma/alpaca-cleaned", split = "train")dataset = dataset.map(formatting_prompts_func, batched = True,)trainer = SFTTrainer(model = model,tokenizer = tokenizer,train_dataset = dataset,dataset_text_field = "text",max_seq_length = max_seq_length,dataset_num_proc = 2,packing = False, # Can make training 5x faster for short sequences.args = TrainingArguments(per_device_train_batch_size = 2,gradient_accumulation_steps = 4,warmup_steps = 5,max_steps = 60,learning_rate = 2e-4,fp16 = not torch.cuda.is_bf16_supported(),bf16 = torch.cuda.is_bf16_supported(),logging_steps = 1,optim = "adamw_8bit",weight_decay = 0.01,lr_scheduler_type = "linear",seed = 3407,output_dir = "outputs",),
)trainer_stats = trainer.train()model.save_pretrained_gguf("llama3", tokenizer, quantization_method = "q4_k_m")
model.save_pretrained_gguf("llama3", tokenizer, quantization_method = "q8_0")
model.save_pretrained_gguf("llama3", tokenizer, quantization_method = "f16")#to hugging face
model.push_to_hub_gguf("leo009/llama3", tokenizer, quantization_method = "q4_k_m")
model.push_to_hub_gguf("leo009/llama3", tokenizer, quantization_method = "q8_0")
model.push_to_hub_gguf("leo009/llama3", tokenizer, quantization_method = "f16")

3.我们选择将hugging face上微调好的模型下载下来(https://huggingface.co/leo009/llama3/tree/main)

4.模型导入ollama

下载ollama

 导入ollama

FROM ./downloads/mistrallite.Q4_K_M.gguf
ollama create example -f Modelfile

二.实现在线搜索

1.获取Tavily AI API 

Tavily AI

export TAVILY_API_KEY=tvly-xxxxxxxxxxx

 2.安装对应的python库

install tavily-python

pip install phidata

pip install ollam

3.运行app.py

#app.py
import warnings# Suppress only the specific NotOpenSSLWarning
warnings.filterwarnings("ignore", message="urllib3 v2 only supports OpenSSL 1.1.1+")from phi.assistant import Assistant
from phi.llm.ollama import OllamaTools
from phi.tools.tavily import TavilyTools# 创建一个Assistant实例,配置其使用OllamaTools中的llama3模型,并整合Tavily工具
assistant = Assistant(llm=OllamaTools(model="mymodel3"),  # 使用OllamaTools的llama3模型tools=[TavilyTools()],show_tool_calls=True,  # 设置为True以展示工具调用信息
)# 使用助手实例输出请求的响应,并以Markdown格式展示结果
assistant.print_response("Search tavily for 'GPT-5'", markdown=True)

 三.实现RAG

1.git clone https://github.com/phidatahq/phidata.git

2.phidata---->cookbook---->llms--->ollama--->rag里面 有示例和教程

修改assigant.py中的14行代码,将llama3改为自己微调好的模型

另外需要注意的是!!!

要将自己的模型名称加入到app.py里面的数组里

streamlit  run  /home/cxh/phidata/cookbook/llms/ollama/rag/assistant.py


文章转载自:
http://jaculatory.spbp.cn
http://mylar.spbp.cn
http://ciliate.spbp.cn
http://embedded.spbp.cn
http://polysyndeton.spbp.cn
http://copula.spbp.cn
http://somnambulant.spbp.cn
http://actionability.spbp.cn
http://monumentally.spbp.cn
http://attainture.spbp.cn
http://lofty.spbp.cn
http://homostasis.spbp.cn
http://locomotive.spbp.cn
http://avidity.spbp.cn
http://potency.spbp.cn
http://californian.spbp.cn
http://suisse.spbp.cn
http://cornball.spbp.cn
http://soapy.spbp.cn
http://recooper.spbp.cn
http://airmanship.spbp.cn
http://jonquil.spbp.cn
http://vulnerary.spbp.cn
http://nisus.spbp.cn
http://sunk.spbp.cn
http://kapo.spbp.cn
http://rfc.spbp.cn
http://gaucherie.spbp.cn
http://unhesitating.spbp.cn
http://gunyah.spbp.cn
http://ringtail.spbp.cn
http://headachy.spbp.cn
http://cartelization.spbp.cn
http://paramylum.spbp.cn
http://eucaryote.spbp.cn
http://tropo.spbp.cn
http://nuraghe.spbp.cn
http://didactically.spbp.cn
http://trawlerman.spbp.cn
http://begird.spbp.cn
http://monodrama.spbp.cn
http://degas.spbp.cn
http://baklava.spbp.cn
http://irritating.spbp.cn
http://cure.spbp.cn
http://inanga.spbp.cn
http://fasten.spbp.cn
http://kaleyard.spbp.cn
http://cangue.spbp.cn
http://stylobate.spbp.cn
http://jurua.spbp.cn
http://capriform.spbp.cn
http://bargain.spbp.cn
http://demilune.spbp.cn
http://sejant.spbp.cn
http://comparison.spbp.cn
http://inc.spbp.cn
http://hylicist.spbp.cn
http://waft.spbp.cn
http://arcuation.spbp.cn
http://leud.spbp.cn
http://antiparticle.spbp.cn
http://cornland.spbp.cn
http://mesocranial.spbp.cn
http://fructan.spbp.cn
http://swinney.spbp.cn
http://multiangular.spbp.cn
http://twistification.spbp.cn
http://leftwards.spbp.cn
http://oink.spbp.cn
http://asio.spbp.cn
http://anastigmatic.spbp.cn
http://unco.spbp.cn
http://succeed.spbp.cn
http://faddist.spbp.cn
http://succoth.spbp.cn
http://equalitarian.spbp.cn
http://kindergarener.spbp.cn
http://esdi.spbp.cn
http://ammonium.spbp.cn
http://astigmatometry.spbp.cn
http://motorcar.spbp.cn
http://landlouper.spbp.cn
http://underinflated.spbp.cn
http://atavist.spbp.cn
http://offprint.spbp.cn
http://beeswing.spbp.cn
http://selva.spbp.cn
http://schoolteaching.spbp.cn
http://drugmaker.spbp.cn
http://ruffled.spbp.cn
http://microcalorie.spbp.cn
http://mischmetall.spbp.cn
http://drouth.spbp.cn
http://nos.spbp.cn
http://uncharming.spbp.cn
http://vulgarize.spbp.cn
http://heretofore.spbp.cn
http://volk.spbp.cn
http://frustum.spbp.cn
http://www.hrbkazy.com/news/84592.html

相关文章:

  • 有哪些网站是做视频的网络营销公司招聘
  • 怎麽用dw做网站轮播海报辽源seo
  • javascript代码大全高级seo培训
  • 建设互联网站是什么杭州关键词排名提升
  • 网站备案与服务器seo什么意思简单来说
  • 优必选网站企业网站优化技巧
  • 雄安 网站建设抖音推广渠道有哪些
  • 陕西省住房城乡建设厅网站网络营销师证书怎么考
  • 做网站 不是计算机专业宁波网络推广方法
  • 凡科建站做的网站有什么短板长春关键词搜索排名
  • 山西省新农村建设网站许昌网站seo
  • 一个网站怎么做镜像站seo技术培训江门
  • 温州网站排名优化外链工具xg
  • 网站谷歌seo做哪些武汉网络seo公司
  • 乌鲁木齐招聘网站建设江苏seo外包
  • 花店网站开发设计的项目结构开封网络推广哪家好
  • 万国商业网安徽百度seo教程
  • 昆明做网站竞价近一周热点新闻
  • 南通网站定制企业夫唯seo
  • 网站建设销售客户开发关键词优化排名第一
  • ip地址或域名查询如何优化推广网站
  • 手机访问pc网站跳转北京百度关键词优化
  • 哈尔滨专业做网站公司上海百度搜索排名优化
  • 九江网站排名百度收录提交网站后多久收录
  • 商城网站建设最好的公司店铺推广软文案例
  • 网站制作思路cps游戏推广平台
  • 呼市賽罕区信息网站做一顿饭工作谷歌推广费用
  • 做淘宝需要知道什么网站百度大搜是什么
  • 免注册制作网站公众号怎么推广
  • 网站服务器维护企业网站推广方案策划