tgoop.com/pytorch_howsam/514
Create:
Last Update:
Last Update:
.
بعد از معرفی شبکه KAN، حالا کارهای مختلفی مبتنی بر این شبکه داره انجام میشه. یکی از کارهای جالب، ترکیب GPT و KAN هست. در ریپوی گیتهاب زیر، دو کد minGPT با pyKAN ترکیب شده. نمونه کدش:
from kan_gpt.model import GPT
from transformers import GPT2Tokenizer
model_config = GPT.get_default_config()
model_config.model_type = "gpt2"
model_config.vocab_size = 50257
model_config.block_size = 1024
model = GPT(model_config)
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
prompt = "Bangalore is often described as the "
prompt_encoded = tokenizer.encode(
text=prompt, add_special_tokens=False
)
x = torch.tensor(prompt_encoded).unsqueeze(0)
model.eval()
y = model.generate(x, 50) # sample 50 tokens
result = tokenizer.decode(y)
print(result)
# Bangalore is often described as the Silicon Valley of India.
# The city has witnessed rapid growth in the past two decades.....
لینک ریپوی گیتهاب KAN-GPT
@pytorch_howsam
BY PyTorch Howsam
Share with your friend now:
tgoop.com/pytorch_howsam/514