설치한 임베딩 모델 확인해보는 법
터미널(PowerShell 또는 CMD) 에서 아래 실행:
curl http://localhost:11434/api/tags
설치된 모델 목록(JSON)이 나오면 서버가 정상 실행 중인 것이다.
bge-m3:567m으로 임베딩 생성하기
임베딩 모델을 다운로드했으니 테스트를 위해 벡터를 생성해보자. 공식 ollama Python 라이브러리를 사용한다.
설치되어 있지 않다면 pip install ollama를 실행한다.
다음은 텍스트 조각에 대한 임베딩을 생성하는 간단한 Python 스크립트다.
import ollama# Define the model name as downloadedEMBEDDING_MODEL = 'bge-m3:567m'def get_embedding(text: str): """Generates an embedding for a given text.""" try: response = ollama.embeddings( model=EMBEDDING_MODEL, prompt=text ) return response['embedding'] except Exception as e: print(f"An error occurred: {e}") return None# --- Example Usage ---sentence = "Ollama makes it easy to run LLMs locally."embedding = get_embedding(sentence)if embedding: print(f"Embedding for: '{sentence}'") # Print the first few dimensions for brevity print(f"First 5 dimensions: {embedding[:5]}") print(f"Total dimensions: {len(embedding)}")
이 스크립트는 생성된 벡터의 처음 다섯 개 값과 전체 크기(Total dimensions)를 출력한다. 숫자 배열(벡터)이 잘 출력된다면 Dify에서도 그대로 쓸 수 있다.