Commit ·
4775cda
1
Parent(s): 565d377
Update app.py
Browse files81 unmodified lines8283848586878586878889905 unmodified lines96979899100991001011021051031041051061091071081121091101111 unmodified line1131141151201161171186 unmodified lines12512612713312812913013113213313914013413513613781 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 -----------------------------------')
# 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_3
print('Control 1-----------------------------------') llm = Llama( model_path="models/Meta-Llama-3-70B-Instruct-Q3_K_M.gguf", flash_attn=True, n_gpu_layers=81, n_gpu_layers=-1, n_batch=1024, n_ctx=8192, ) print('Control 2-----------------------------------')
provider = LlamaCppPythonProvider(llm) print('Control 3-----------------------------------') agent = LlamaCppAgent( provider,1 unmodified line predefined_messages_formatter_type=chat_template, debug_output=True ) print('Control 4-----------------------------------') settings = provider.get_provider_default_settings() settings.temperature = 0.76 unmodified lines messages = BasicChatHistory()
stream = agent.get_chat_response( prompt, prompt + ' : ' + pdftext, 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 += outputapp.py+6-12