-
Ollama python 모델 실행하기.DEV/nlp 2024. 10. 28. 14:16
ollama 모델 설치 참고
https://seokbong.tistory.com/303
Mac OS / Windows Ollama로 eeve 모델 설치하여 사용하기
M1, M2, M3 실리콘 맥 시리즈에서 Ollama로 eeve를 등록하여 사용해 보았습니다.(Windows도 동작 확인 완료) ollama install : https://github.com/ollama/ollama GitHub - ollama/ollama: Get up and running with Llama 3.1, Mistral, Gemm
seokbong.tistory.com
응답 값을 Stream으로 받는 방법
import ollama # pip install ollama stream = ollama.chat( model='eeve:q4', # 모델명 입력 messages=[ { 'role': 'User', 'content': message, # prompt } ], stream=True, # 응답값 streaming으로 받을지 결정하는 option ) # 응답값을 stream으로 받는 경우 아래와 같이 출력 가능 for chunk in stream: print(chunk['message']['content'])
일반적인 응답 방식
import ollama response = ollama.chat(model='llama3.1', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ]) print(response['message']['content'])
ref https://github.com/ollama/ollama-python
GitHub - ollama/ollama-python: Ollama Python library
Ollama Python library. Contribute to ollama/ollama-python development by creating an account on GitHub.
github.com
'DEV > nlp' 카테고리의 다른 글
Openmanus + Ollama 내장 모델 사용하기. (0) 2025.03.26 서버에 Open WebUI 올려서 서빙하기 / LLM 모델 사용하기 (0) 2025.03.24 Mac OS / Windows Ollama로 eeve 모델 설치하여 사용하기 (2) 2024.09.25 NLP 자연어 처리 정리 1 (0) 2024.08.22 LLaMA2 Meta의 LLM... (1) 2024.04.18