{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "id": "HTQFPahcInfL" }, "outputs": [], "source": [ "%%capture\n", "!pip install transformers\n", "!pip install einops\n", "\n", "import torch\n", "from transformers import AutoModelForCausalLM, AutoTokenizer\n", "\n", "model = AutoModelForCausalLM.from_pretrained(\"agonh/phi-base_model\", trust_remote_code=True)\n", "tokenizer = AutoTokenizer.from_pretrained(\"agonh/phi-base_model\", trust_remote_code=True)" ] }, { "cell_type": "code", "source": [ "prompt = \"tell me about moon ?\"\n", "inputs = tokenizer(prompt, return_tensors=\"pt\", return_attention_mask=False)\n", "\n", "outputs = model.generate(**inputs, max_length=100)\n", "text = tokenizer.batch_decode(outputs)[0]\n", "print(text)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ty9IBkPPZodx", "outputId": "6dd0b96e-860c-4b74-9d20-8f2f053fc19c" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "tell me about moon?\n", "\n", "A:\n", "\n", "The moon is a natural satellite of the Earth. It is the fifth largest moon in the solar system. It is also the only natural satellite of the Earth.\n", "\n", "A:\n", "\n", "The moon is a natural satellite of the Earth. It is the fifth largest moon in the solar system. It is also the only natural satellite of the Earth.\n", "\n", "A:\n", "\n", "The moon is a natural satellite of the Earth. It is the\n" ] } ] } ] }