Commit ·
c6fe983
1
Parent(s): fae1c05
Update app.py
Browse files81 unmodified lines82838485868717 unmodified lines1051061071081091101113 unmodified lines11511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416581 unmodified lines@spaces.GPU(duration=120)def deidentify_doc(pdftext, maxtokens, temperature, top_probability):# prompt = "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]"# prompt = """# Perform the following actions on given report:17 unmodified lines# n_ctx=8192,# )# chat_template = MessagesFormatterType.LLAMA_3llm = Llama(model_path="models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf",3 unmodified linesn_ctx=8192,)# provider = LlamaCppPythonProvider(llm)# agent = LlamaCppAgent(# provider,# system_prompt="You are a helpful assistant.",# predefined_messages_formatter_type=chat_template,# debug_output=True# )# settings = provider.get_provider_default_settings()# settings.temperature = 0.7# settings.top_k = 40# settings.top_p = 0.95# settings.max_tokens = 2048# settings.repeat_penalty = 1.1# settings.stream = True# messages = BasicChatHistory()# stream = agent.get_chat_response(# prompt + ' : ' + pdftext,# llm_sampling_settings=settings,# chat_history=messages,# returns_streaming_generator=True,# print_output=False# )# outputs = ""# for output in stream:# outputs += output# return outputsoutput = 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 = model.create_chat_completion(81 unmodified lines8283848586878817 unmodified lines1061071081091101111123 unmodified lines11611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316481 unmodified lines@spaces.GPU(duration=120)def deidentify_doc(pdftext, maxtokens, temperature, top_probability):# prompt = "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]"# prompt = """# Perform the following actions on given report:17 unmodified lines# n_ctx=8192,# )chat_template = MessagesFormatterType.LLAMA_3llm = Llama(model_path="models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf",3 unmodified linesn_ctx=8192,)provider = LlamaCppPythonProvider(llm)agent = LlamaCppAgent(provider,system_prompt="You are a helpful assistant.",predefined_messages_formatter_type=chat_template,debug_output=True)settings = provider.get_provider_default_settings()settings.temperature = temperaturesettings.top_k = 40settings.top_p = top_probabilitysettings.max_tokens = maxtokenssettings.repeat_penalty = 1.1settings.stream = Truemessages = BasicChatHistory()stream = agent.get_chat_response(prompt + ' : ' + pdftext,llm_sampling_settings=settings,chat_history=messages,returns_streaming_generator=True,print_output=False)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 = model.create_chat_completion(
app.py+41-42