Skip to content

Commit

Permalink
misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil committed Sep 4, 2024
1 parent c5c2176 commit 163777e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
21 changes: 11 additions & 10 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from py_txi.text_embedding_inference import TEI, TEIConfig
from py_txi.text_generation_inference import TGI, TGIConfig

llm = TGI(config=TGIConfig(model_id="bigscience/bloom-560m", gpus="0"))
output = llm.generate(["Hi, I'm a language model", "I'm fine, how are you?"])
print(len(output))
print("LLM:", output)
llm.close()
for gpus in [None, "1", "1,2"]:
llm = TGI(config=TGIConfig(model_id="bigscience/bloom-560m", gpus=gpus))
output = llm.generate(["Hi, I'm a language model", "I'm fine, how are you?"])
print(len(output))
print("LLM:", output)
llm.close()

embed = TEI(config=TEIConfig(model_id="BAAI/bge-base-en-v1.5"))
output = embed.encode(["Hi, I'm an embedding model", "I'm fine, how are you?"])
print(len(output))
print("Embed:", output)
embed.close()
embed = TEI(config=TEIConfig(model_id="BAAI/bge-base-en-v1.5", gpus=gpus))
output = embed.encode(["Hi, I'm an embedding model", "I'm fine, how are you?"])
print(len(output))
print("Embed:", output)
embed.close()
6 changes: 3 additions & 3 deletions py_txi/text_embedding_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def __post_init__(self) -> None:

if self.image is None:
if is_nvidia_system() and self.gpus is not None:
LOGGER.info("\t+ Using the latest NVIDIA GPU image for Text-Embedding-Inference")
self.image = "ghcr.io/huggingface/text-embeddings-inference:latest"
LOGGER.info("\t+ Using latest NVIDIA CUDA GPU image for Text-Embedding-Inference")
self.image = "ghcr.io/huggingface/text-embeddings-inference:cuda-latest"
else:
LOGGER.info("\t+ Using version 1.4 image for Text-Embedding-Inference")
LOGGER.info("\t+ Using CPU image version 1.4 for Text-Embedding-Inference (before onnx backend)")
self.image = "ghcr.io/huggingface/text-embeddings-inference:cpu-1.4"

if is_nvidia_system() and "cpu" in self.image:
Expand Down
8 changes: 4 additions & 4 deletions py_txi/text_generation_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def __post_init__(self) -> None:

if self.image is None:
if is_nvidia_system() and self.gpus is not None:
LOGGER.info("\t+ Using latest NVIDIA GPU image for Text-Generation-Inference")
LOGGER.info("\t+ Using latest NVIDIA CUDA GPU image for Text-Generation-Inference")
self.image = "ghcr.io/huggingface/text-generation-inference:latest"
elif is_rocm_system() and self.devices is not None:
LOGGER.info("\t+ Using latest ROCm AMD GPU image for Text-Generation-Inference")
LOGGER.info("\t+ Using latest AMD ROCm GPU image for Text-Generation-Inference")
self.image = "ghcr.io/huggingface/text-generation-inference:latest-rocm"
else:
LOGGER.info("\t+ Using version 1.4 image for Text-Generation-Inference (last image with CPU support)")
self.image = "ghcr.io/huggingface/text-generation-inference:1.4"
LOGGER.info("\t+ Using latest image for Text-Generation-Inference")
self.image = "ghcr.io/huggingface/text-generation-inference:latest"

if is_rocm_system() and "rocm" not in self.image:
LOGGER.warning("\t+ You are running on a ROCm AMD GPU system but using a non-ROCM image.")
Expand Down

0 comments on commit 163777e

Please sign in to comment.