Commit ·
4775cda
1
Parent(s): 565d377
Update app.py
Browse files81 unmodified lines8283848586878889905 unmodified lines969798991001011021031041051061071081091101111121131141151 unmodified line1171181191201211221236 unmodified lines13013113213313413513613713813914014114214381 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]"print('Control 0.5 -----------------------------------')# model_id = "models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf"# # model = Llama(model_path=model_id, n_ctx=2048, n_threads=8, n_gpu_layers=-1, n_batch=128)# model = Llama(5 unmodified lines# )chat_template = MessagesFormatterType.LLAMA_3print('Control 1-----------------------------------')llm = Llama(model_path="models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf",flash_attn=True,n_gpu_layers=81,n_batch=1024,n_ctx=8192,)print('Control 2-----------------------------------')provider = LlamaCppPythonProvider(llm)print('Control 3-----------------------------------')agent = LlamaCppAgent(provider,1 unmodified linepredefined_messages_formatter_type=chat_template,debug_output=True)print('Control 4-----------------------------------')settings = provider.get_provider_default_settings()settings.temperature = 0.76 unmodified linesmessages = BasicChatHistory()stream = agent.get_chat_response(prompt,llm_sampling_settings=settings,chat_history=messages,returns_streaming_generator=True,print_output=False)print('Control 5-----------------------------------')print(stream)outputs = ""for output in stream:outputs += output81 unmodified lines8283848586878889905 unmodified lines969798991001011021031041051061071081091101111 unmodified line1131141151161171186 unmodified lines12512612712812913013113213313413513613781 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 = "Anonymize the following report"# model_id = "models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf"# # model = Llama(model_path=model_id, n_ctx=2048, n_threads=8, n_gpu_layers=-1, n_batch=128)# model = Llama(5 unmodified lines# )chat_template = MessagesFormatterType.LLAMA_3llm = Llama(model_path="models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf",flash_attn=True,n_gpu_layers=-1,n_batch=1024,n_ctx=8192,)provider = LlamaCppPythonProvider(llm)agent = LlamaCppAgent(provider,1 unmodified linepredefined_messages_formatter_type=chat_template,debug_output=True)settings = provider.get_provider_default_settings()settings.temperature = 0.76 unmodified linesmessages = 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
app.py+6-12