Commit ·
cd5a3f1
1
Parent(s): e693246
Update app.py
Browse files12 unmodified lines1314151617181966 unmodified lines86878889909192939495969798991001011021034 unmodified lines10810911011111211311411511611711811912012112212312412512625 unmodified lines15215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718812 unmodified linesfrom llama_cpp_agent.providers import LlamaCppPythonProviderfrom llama_cpp_agent.chat_history import BasicChatHistoryfrom llama_cpp_agent.chat_history.messages import Rolesfrom vllm import LLM, SamplingParams# subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)# subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)66 unmodified linesprompt = "In the following text replace any person name and any address with term [redacted], replace any Date of Birth and NHS number with term [redacted]. Output the modified text."# prompt = """# Perform the following actions on given report:# 1. Replace any person names, age, date of birth, gender with term [redacted]# 2. Replace any addresses with term [redacted]# 3. DO NOT REPLACE ANY MEDICAL MEASUREMENTS# 4. Replace only the CALENDAR DATES of format 'day/month/year' with term [redacted]# """# prompt = """# Remove person names, any dates, date of birth, age, gender, registration numbers and any addresses from the following report.# """# model = Llama(# model_path=model_id,# flash_attn=True,4 unmodified lines# chat_template = MessagesFormatterType.LLAMA_3sampling_params = SamplingParams(temperature=0.8, top_p=0.95)# llm = Llama(# model_path="models/Meta-Llama-3-8B-Instruct.Q8_0.gguf",# flash_attn=True,# n_gpu_layers=81,# n_batch=1024,# n_ctx=8192,# )llm = LLM(model="meta-llama/Meta-Llama-3-8B-Instruct")outputs = llm.generate([prompt], sampling_params)output = outputs[0].outputs[0].text# provider = LlamaCppPythonProvider(llm)25 unmodified lines# output = ""# for op in stream:# output += op# output = llm.create_chat_completion(# messages=[# {"role": "assistant", "content": prompt},# {# "role": "user",# "content": pdftext# }# ],# max_tokens=maxtokens,# temperature=temperature# )# output = output['choices'][0]['message']['content']prompt = "Perform the following actions on given text: 1. Replace any person age with term [redacted] 2. DO NOT REPLACE ANY MEDICAL MEASUREMENTS 3. Replace only the CALENDAR DATES of format 'day/month/year' with term [redacted]. Output the modified text."outputs = llm.generate([output], sampling_params)output = outputs[0].outputs[0].text# output = llm.create_chat_completion(# messages=[# {"role": "assistant", "content": prompt},# {# "role": "user",# "content": output# }# ],# max_tokens=maxtokens,# temperature=temperature# )# output = output['choices'][0]['message']['content']# print(prompt)# print(output)12 unmodified lines1314151617181966 unmodified lines8687888990914 unmodified lines9697989910010110210310410510625 unmodified lines13213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517612 unmodified linesfrom llama_cpp_agent.providers import LlamaCppPythonProviderfrom llama_cpp_agent.chat_history import BasicChatHistoryfrom llama_cpp_agent.chat_history.messages import Roles# from vllm import LLM, SamplingParams# subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)# subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)66 unmodified linesprompt = "In the following text replace any person name and any address with term [redacted], replace any Date of Birth and NHS number with term [redacted]. Output the modified text."# model = Llama(# model_path=model_id,# flash_attn=True,4 unmodified lines# chat_template = MessagesFormatterType.LLAMA_3# sampling_params = SamplingParams(temperature=0.8, top_p=0.95)# llm = LLM(model="meta-llama/Meta-Llama-3-8B-Instruct")# outputs = llm.generate([prompt], sampling_params)# output = outputs[0].outputs[0].text# provider = LlamaCppPythonProvider(llm)25 unmodified lines# output = ""# for op in stream:# output += opllm = Llama(model_path="models/Meta-Llama-3-8B-Instruct.Q8_0.gguf",flash_attn=True,n_gpu_layers=81,n_batch=1024,n_ctx=8192,)output = llm.create_chat_completion(messages=[{"role": "assistant", "content": prompt},{"role": "user","content": pdftext}],max_tokens=maxtokens,temperature=temperature)output = output['choices'][0]['message']['content']prompt = "Perform the following actions on given text: 1. Replace any person age with term [redacted] 2. DO NOT REPLACE ANY MEDICAL MEASUREMENTS 3. Replace only the CALENDAR DATES of format 'day/month/year' with term [redacted]. Output the modified text."# outputs = llm.generate([output], sampling_params)# output = outputs[0].outputs[0].textoutput = llm.create_chat_completion(messages=[{"role": "assistant", "content": prompt},{"role": "user","content": output}],max_tokens=maxtokens,temperature=temperature)output = output['choices'][0]['message']['content']# print(prompt)# print(output)
app.py+39-51