AI & ML interests

Being Ryan Gosling, being Patrick Bateman, watching Blade Runner 2049 (2017) on repeat, rewatching American Psycho (2000), watching Barbie (2023). Get Kenergetic!

Recent Activity

KaraKaraWitchย 
posted an update about 1 month ago
view post
Post
285
What if LLMs used thinking emojis to develop their state?

:blob_think: Normal Thinking
:thinkies: Casual Thinking
:Thonk: Serious Thinking
:think_bold: Critical Thinking
:thinkspin: Research Thinking
:thinkgod: Deep Research Thinking

The last 2 are gifs. But the upload doesn't render them :)

(Credits: SwayStar123 on EAI suggested it to be a range selector, Original base idea was from me)
  • 1 reply
ยท
KaraKaraWitchย 
posted an update 3 months ago
view post
Post
313
"What's wrong with using huggingface transformers?"

Here's a quick example. Am I supposed to be going in with the full knowledge of the inner workings of a LLM model?
import pathlib
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("<ModernBERT>")
# Triton is **required**, but no where in the documentation is specified that triton is needed.
# Installing triton in windows isn't super straightforward. Thankfully someone has already built wheels for it.
#  - https://github.com/woct0rdho/triton-windows/releases

model = AutoModelForSequenceClassification.from_pretrained(
    "<ModernBERT>",  # reference_compile=False
)
# By default it uses CPU. Which is slow. Move to a cuda device.
# This will actually error out if you use "gpu" instead.
model = model.to("cuda")


with torch.no_grad():
    # Not setting `return_tensors="pt"` causes
    #   File "C:\Program Files\Python310\lib\site-packages\transformers\modeling_utils.py", line 5311, in warn_if_padding_and_no_attention_mask
    #     if self.config.pad_token_id in input_ids[:, [-1, 0]]:
    #   TypeError: list indices must be integers or slices, not tuple
    # or...
    #  File "C:\Program Files\Python310\lib\site-packages\transformers\models\modernbert\modeling_modernbert.py", line 836, in forward
    #    batch_size, seq_len = input_ids.shape[:2]
    #  AttributeError: 'list' object has no attribute 'shape'
    block = tokenizer(
        pathlib.Path("test-fic.txt").read_text("utf-8"), return_tensors="pt"
    )
    block = block.to("cuda")
    # **block is needed to fix "AttributeError: 'NoneType' object has no attribute 'unsqueeze'" on attention_mask.unsqueeze(-1)
    logits = model(**block).logits

# Not moving to cpu will cause the sigmoid/softmax ops to fail.
logits = logits.to("cpu")
# print(logits)
predicted_class_ids = torch.softmax(logits, -1)[
    0
].numpy()

  • 3 replies
ยท
KaraKaraWitchย 
posted an update 3 months ago
view post
Post
2738
> New Model
> Looks at Model Card
> "Open-Weights"
  • 1 reply
ยท
not-lainย 
posted an update 6 months ago
not-lainย 
posted an update 7 months ago
not-lainย 
posted an update 7 months ago
view post
Post
1796
we now have more than 2000 public AI models using ModelHubMixin๐Ÿค—
not-lainย 
posted an update 8 months ago
view post
Post
4139
Published a new blogpost ๐Ÿ“–
In this blogpost I have gone through the transformers' architecture emphasizing how shapes propagate throughout each layer.
๐Ÿ”— https://huggingface.co/blog/not-lain/tensor-dims
some interesting takeaways :
not-lainย 
posted an update 9 months ago
view post
Post
2452
ever wondered how you can make an API call to a visual-question-answering model without sending an image url ๐Ÿ‘€

you can do that by converting your local image to base64 and sending it to the API.

recently I made some changes to my library "loadimg" that allows you to make converting images to base64 a breeze.
๐Ÿ”— https://github.com/not-lain/loadimg

API request example ๐Ÿ› ๏ธ:
from loadimg import load_img
from huggingface_hub import InferenceClient

# or load a local image
my_b64_img = load_img(imgPath_url_pillow_or_numpy ,output_type="base64" ) 

client = InferenceClient(api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

messages = [
	{
		"role": "user",
		"content": [
			{
				"type": "text",
				"text": "Describe this image in one sentence."
			},
			{
				"type": "image_url",
				"image_url": {
					"url": my_b64_img # base64 allows using images without uploading them to the web
				}
			}
		]
	}
]

stream = client.chat.completions.create(
    model="meta-llama/Llama-3.2-11B-Vision-Instruct", 
	messages=messages, 
	max_tokens=500,
	stream=True
)

for chunk in stream:
    print(chunk.choices[0].delta.content, end="")
Blane187ย 
posted an update about 1 year ago
not-lainย 
posted an update about 1 year ago
Blane187ย 
posted an update about 1 year ago
view post
Post
1457
hello everyone, today I have been working on a project Blane187/rvc-demo, a demo of rvc using pip, this project is still a demo though (I don't have a beta tester lol)
not-lainย 
posted an update about 1 year ago
view post
Post
7818
I am now a huggingface fellow ๐Ÿฅณ
ยท
not-lainย 
posted an update about 1 year ago
view post
Post
2718
I have finished writing a blogpost about building an image-based retrieval system, This is one of the first-ever approaches to building such a pipeline using only open-source models/libraries ๐Ÿค—

You can checkout the blogpost in https://huggingface.co/blog/not-lain/image-retriever and the associated space at not-lain/image-retriever .

โœจ If you want to request another blog post consider letting me know down below or you can reach out to me through any of my social media

๐Ÿ“– Happy reading !
not-lainย 
posted an update about 1 year ago
view post
Post
1486
Hello beautiful people.
I wanted to thank everyone that read my blogpost and I am glad to share that we have achieved 11000 readers ๐Ÿฅณ
I couldn't have done this without you, so once again thanks a lot everyone for the support ๐Ÿ’–
If you haven't already you can read my blog post at: https://huggingface.co/blog/not-lain/rag-chatbot-using-llama3
Korakoeย 
posted an update about 1 year ago
not-lainย 
posted an update about 1 year ago
view post
Post
2140
It is with great pleasure I inform you that huggingface's ModelHubMixin reached 200+ models on the hub ๐Ÿฅณ

ModelHubMixin is a class developed by HF to integrate AI models with the hub with ease and it comes with 3 methods :
* save_pretrained
* from_pretrained
* push_to_hub

Shoutout to @nielsr , @Wauplin and everyone else on HF for their awesome work ๐Ÿค—

If you are not familiar with ModelHubMixin and you are looking for extra resources you might consider :
* docs: https://huggingface.co/docs/huggingface_hub/main/en/package_reference/mixins
๐Ÿ”—blog about training models with the trainer API and using ModelHubMixin: https://huggingface.co/blog/not-lain/trainer-api-and-mixin-classes
๐Ÿ”—GitHub repo with pip integration: https://github.com/not-lain/PyTorchModelHubMixin-template
๐Ÿ”—basic guide: https://huggingface.co/posts/not-lain/884273241241808
not-lainย 
posted an update about 1 year ago
view post
Post
1963
I will be delivering an introductory coding session this Sunday 7Pm gmt+1 time about huggingface, if you are new to HF and don't know where to begin, you are welcome to join us ๐Ÿค—
๐Ÿ“ŒPlace: huggingface discord server
๐Ÿ”—Link : https://discord.gg/hugging-face-879548962464493619?event=1245406127668203541
  • 2 replies
ยท