{"id":459620,"date":"2025-05-14T09:21:18","date_gmt":"2025-05-14T09:21:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459620"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459620","title":{"rendered":"<span>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u043c VPS: FastAPI + Hugging Face \u0437\u0430 15 \u043c\u0438\u043d\u0443\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u0435\u043c Python \u0438 Docker. \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 Hugging Face \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u043c VPS-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c HTTP-\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439. \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u0445 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u0438 \u0447\u0435\u0440\u0435\u0437 15 \u043c\u0438\u043d\u0443\u0442 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441..<\/em><\/p>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 VPS \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f, \u0430 \u0442\u0435, \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439. \u041d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u2014 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e! \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0430 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d python. \u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f FastAPI \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f API \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 Docker \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><strong>\u0427\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0430 HuggingFace<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0448\u0430 \u043b\u044e\u0431\u0438\u043c\u0430\u044f IDE<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 Space<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/huggingface.co\/spaces\" rel=\"noopener noreferrer nofollow\">Hugging Face Spaces<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>&#171;New Space&#187;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>Docker<\/strong> (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e!) \u2192 FastAPI \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 <strong>Gradio<\/strong>-\u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 docker template \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 Blank. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u00bb<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">git clone https:\/\/huggingface.co\/spaces\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_space <\/code><\/pre>\n<p><strong>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/strong><\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 \u0432\u0430\u0448\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 IDE \u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<p>\/your_project_root<br \/> \u2502<br \/> \u251c\u2500\u2500 .gitattributes<br \/> \u251c\u2500\u2500 Dockerfile<br \/> \u251c\u2500\u2500 README.md<br \/> \u251c\u2500\u2500 main.py<br \/> \u2514\u2500\u2500 requirements.txt<\/p>\n<p>\u0420\u0438\u0441.1 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<p><strong>\u041e\u043f\u0438\u0448\u0435\u043c Dockerfile<\/strong><\/p>\n<pre><code class=\"bash\">FROM python:3.9-slim  WORKDIR \/app  RUN apt-get update &amp;&amp; \\ apt-get install -y --no-install-recommends git g++ make &amp;&amp; \\ apt-get clean &amp;&amp; \\ rm -rf \/var\/lib\/apt\/lists\/*  COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt  COPY main.py .  ENV HF_HOME=\/tmp\/huggingface-cache ENV TOKENIZERS_PARALLELISM=false  EXPOSE 7860 CMD [\"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"] <\/code><\/pre>\n<p>\u0420\u0438\u0441.2 Dockerfile<\/p>\n<p>Dockerfile \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0445\u043e\u0447\u0443 \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435<\/p>\n<p><em>ENV HF_HOME=\/tmp\/huggingface-cache:<\/em><\/p>\n<blockquote>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f HF_HOME, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 Hugging Face \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u044d\u0448 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/tmp.<\/p>\n<\/blockquote>\n<p><em>ENV TOKENIZERS_PARALLELISM=false:<\/em><\/p>\n<blockquote>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f TOKENIZERS_PARALLELISM \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 false, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 Hugging Face.<\/p>\n<\/blockquote>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"bash\">fastapi==0.109.0 uvicorn==0.27.0 torch==2.2.1 --index-url https:\/\/download.pytorch.org\/whl\/cpu transformers==4.40.2 accelerate==0.29.3 sentencepiece==0.2.0 numpy==1.26.4 protobuf==3.20.3 <\/code><\/pre>\n<p>\u0420\u0438\u0441.3 \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e API \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 <em>TinyLlama\/TinyLlama-1.1B-Chat-v1.0.<\/em>  \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u0438 \u0434\u0430\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u0432\u0430\u0448\u0438\u043c \u043d\u0443\u0436\u0434\u0430\u043c.<\/p>\n<pre><code class=\"python\">from fastapi import FastAPI, HTTPException from pydantic import BaseModel from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline import torch import numpy as np  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 NumPy assert np.__version__.startswith('1.'), f\"\u041d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f NumPy: {np.__version__}\"  app = FastAPI()  class RequestData(BaseModel):     prompt: str     max_tokens: int = 50  MODEL_NAME = \"TinyLlama\/TinyLlama-1.1B-Chat-v1.0\"  try:     # \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u044f\u0432\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c device_map     tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)     model = AutoModelForCausalLM.from_pretrained(         MODEL_NAME,         torch_dtype=torch.float32,         device_map=\"auto\",         low_cpu_mem_usage=True     )          # \u0421\u043e\u0437\u0434\u0430\u0435\u043c pipeline \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f device     generator = pipeline(         \"text-generation\",         model=model,         tokenizer=tokenizer     ) except Exception as e:     print(f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438: {str(e)}\")     generator = None  @app.post(\"\/generate\") async def generate_text(request: RequestData):     if not generator:         raise HTTPException(status_code=503, detail=\"\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430\")          try:         output = generator(             request.prompt,             max_new_tokens=min(request.max_tokens, 100),             do_sample=False,             num_beams=1,             temperature=0.7,         )         return {\"response\": output[0][\"generated_text\"]}     except Exception as e:         raise HTTPException(status_code=500, detail=str(e))  @app.get(\"\/health\") async def health_check():     return {\"status\": \"ok\" if generator else \"unavailable\"} <\/code><\/pre>\n<p>\u0420\u0438\u0441.4 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f,  \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/generate \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 json. \u041e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044f \u0445\u043e\u0447\u0443 \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u0449\u0435\u043c\u0443 \u0431\u043b\u043e\u043a\u0443 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\">        output = generator(             request.prompt,             max_new_tokens=min(request.max_tokens, 100),             do_sample=False,             num_beams=1,             temperature=0.7,         ) <\/code><\/pre>\n<p>\u0420\u0438\u0441.5. \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u043f\u0446\u0438\u0439<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u043c\u0438, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a Hugging Face Transformers. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u043f\u0446\u0438\u0439 \u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u043e\u043c\u0438\u0442\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0448\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<br \/> \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 CI\/CD. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/huggingface.co\/spaces\/%D0%B2%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5_%D0%B8%D0%BC%D1%8F_%D0%B2%D0%B0%D1%88%D0%B5%D0%B3%D0%BE_%D0%B0%D0%BA%D0%BA%D0%B0%D1%83%D0%BD%D1%82%D0%B0\/%D0%B2%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5_%D0%B8%D0%BC%D1%8F_%D0%B2%D0%B0%D1%88%D0%B5%D0%B3%D0%BE_spaces?logs=container\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/spaces\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_spaces?logs=container<\/a><\/p>\n<p>\u0418 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0441\u0431\u043e\u0440\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">curl -X POST \"https:\/\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430-\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_spaces .hf.space\/generate\" \u00a0\u00a0-H \"Content-Type: application\/json\" \u00a0\u00a0-d '{\"prompt\":\"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0433\u043e\u0434\u0430?\"}' <\/code><\/pre>\n<p>\u0420\u0438\u0441. 6 curl \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"json\">{\"response\":\"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Docker?\\n\\nDocker - \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Linux \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Linux\" <\/code><\/pre>\n<p>\u0420\u0438\u0441.7 \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u0435\u043c! \u0412\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u0432\u0430\u0448\u0435\u043c VPS, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 Spaces \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 Hugging Face \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u043e\u0431\u0449\u0438\u0445 CPU\/GPU \u0438 \u0438\u043c\u0435\u044e\u0442 \u0440\u044f\u0434 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u0415\u0441\u043b\u0438 \u043a API \u043d\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 48 \u0447\u0430\u0441\u043e\u0432, Space &#171;\u0443\u0441\u043d\u0451\u0442&#187;. \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c (\u043e\u043a\u043e\u043b\u043e 30 \u0441\u0435\u043a\u0443\u043d\u0434).<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432: \u0417\u0430\u043f\u0440\u043e\u0441\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 1-2 \u043c\u0438\u043d\u0443\u0442, \u0431\u0443\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 GPU: \u041c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 CPU, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442:<\/p>\n<ul>\n<li>\n<p>\u0421\u043f\u044f\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c: \u0415\u0441\u043b\u0438 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 Space \u043d\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 48 \u0447\u0430\u0441\u043e\u0432, \u043e\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 &#171;\u0441\u043f\u044f\u0449\u0438\u0439&#187; \u0440\u0435\u0436\u0438\u043c. \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c 30-60 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p>CPU: 1 \u044f\u0434\u0440\u043e, ~1 GB RAM.<\/p>\n<\/li>\n<li>\n<p>GPU (\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e): \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 Space, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043a\u0440\u0443\u0433\u043b\u043e\u0441\u0443\u0442\u043e\u0447\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435: Hugging Face \u043c\u043e\u0436\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c Space, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d \u0431\u043e\u043b\u0435\u0435 90 \u0434\u043d\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041a\u0430\u043a \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c &#171;\u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u044f&#187;?<\/h4>\n<ol>\n<li>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b: \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>cron<\/code> \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/uptimerobot.com\/\" rel=\"noopener noreferrer nofollow\">UptimeRobot<\/a>).<\/p>\n<\/li>\n<li>\n<p>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0442 Hugging Face \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<h4>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b<\/h4>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e <strong>\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/strong> \u2192 <strong>Hugging Face Spaces + FastAPI<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <strong>24\/7 \u0431\u0435\u0437 &#171;\u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u0439&#187;<\/strong> \u2192 <strong>Google Cloud Run<\/strong> \u0438\u043b\u0438 <strong>Fly.io<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d <strong>GPU \u0438 \u043d\u0438\u0437\u043a\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430<\/strong> \u2192 <strong>Hugging Face Inference Endpoints<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435?<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0443, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e.<br \/> \u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043d\u0430 CPU, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c quantization \u2014 \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442 \u0435\u0451 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0435\u0437 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438.<br \/> \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Hugging Face Inference Endpoints \u0438\u043b\u0438 Google Cloud Run \u2014 \u044d\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u044f\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f, \u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a\u0438 \u0438 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0440\u0435\u043f\u043e\u0441\u0442\u044b. <strong>\u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0430.<\/strong> \u0421 \u0432\u0430\u043c\u0438 \u0431\u044b\u043b \u0414\u0443\u0431\u043e\u0432\u0438\u0446\u043a\u0438\u0439 \u042e\u0440\u0438\u0439, \u0430\u0432\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430 <a href=\"https:\/\/t.me\/notReadySir\" rel=\"noopener noreferrer nofollow\">\u00ab\u0412\u0430\u0448 \u043a\u043e\u0434 \u0435\u0449\u0435 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432, \u0441\u044d\u0440\u00bb<\/a>.<br \/> \u0410 \u043d\u0430\u0448 \u043a\u043e\u0434 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432. \u0414\u043e \u0441\u0432\u044f\u0437\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908554\/\"> https:\/\/habr.com\/ru\/articles\/908554\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u0435\u043c Python \u0438 Docker. \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 Hugging Face \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u043c VPS-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c HTTP-\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439. \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u0445 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u0438 \u0447\u0435\u0440\u0435\u0437 15 \u043c\u0438\u043d\u0443\u0442 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441..<\/em><\/p>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 VPS \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f, \u0430 \u0442\u0435, \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439. \u041d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u2014 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e! \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0430 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d python. \u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f FastAPI \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f API \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 Docker \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><strong>\u0427\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0430 HuggingFace<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0448\u0430 \u043b\u044e\u0431\u0438\u043c\u0430\u044f IDE<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 Space<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/huggingface.co\/spaces\" rel=\"noopener noreferrer nofollow\">Hugging Face Spaces<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>&#171;New Space&#187;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>Docker<\/strong> (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e!) \u2192 FastAPI \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 <strong>Gradio<\/strong>-\u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 docker template \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 Blank. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u00bb<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">git clone https:\/\/huggingface.co\/spaces\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_space <\/code><\/pre>\n<p><strong>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/strong><\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 \u0432\u0430\u0448\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 IDE \u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<p>\/your_project_root<br \/> \u2502<br \/> \u251c\u2500\u2500 .gitattributes<br \/> \u251c\u2500\u2500 Dockerfile<br \/> \u251c\u2500\u2500 README.md<br \/> \u251c\u2500\u2500 main.py<br \/> \u2514\u2500\u2500 requirements.txt<\/p>\n<p>\u0420\u0438\u0441.1 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<p><strong>\u041e\u043f\u0438\u0448\u0435\u043c Dockerfile<\/strong><\/p>\n<pre><code class=\"bash\">FROM python:3.9-slim  WORKDIR \/app  RUN apt-get update &amp;&amp; \\ apt-get install -y --no-install-recommends git g++ make &amp;&amp; \\ apt-get clean &amp;&amp; \\ rm -rf \/var\/lib\/apt\/lists\/*  COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt  COPY main.py .  ENV HF_HOME=\/tmp\/huggingface-cache ENV TOKENIZERS_PARALLELISM=false  EXPOSE 7860 CMD [\"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"] <\/code><\/pre>\n<p>\u0420\u0438\u0441.2 Dockerfile<\/p>\n<p>Dockerfile \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0445\u043e\u0447\u0443 \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435<\/p>\n<p><em>ENV HF_HOME=\/tmp\/huggingface-cache:<\/em><\/p>\n<blockquote>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f HF_HOME, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 Hugging Face \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u044d\u0448 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/tmp.<\/p>\n<\/blockquote>\n<p><em>ENV TOKENIZERS_PARALLELISM=false:<\/em><\/p>\n<blockquote>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f TOKENIZERS_PARALLELISM \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 false, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 Hugging Face.<\/p>\n<\/blockquote>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"bash\">fastapi==0.109.0 uvicorn==0.27.0 torch==2.2.1 --index-url https:\/\/download.pytorch.org\/whl\/cpu transformers==4.40.2 accelerate==0.29.3 sentencepiece==0.2.0 numpy==1.26.4 protobuf==3.20.3 <\/code><\/pre>\n<p>\u0420\u0438\u0441.3 \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e API \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 <em>TinyLlama\/TinyLlama-1.1B-Chat-v1.0.<\/em>  \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u0438 \u0434\u0430\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u0432\u0430\u0448\u0438\u043c \u043d\u0443\u0436\u0434\u0430\u043c.<\/p>\n<pre><code class=\"python\">from fastapi import FastAPI, HTTPException from pydantic import BaseModel from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline import torch import numpy as np  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 NumPy assert np.__version__.startswith('1.'), f\"\u041d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f NumPy: {np.__version__}\"  app = FastAPI()  class RequestData(BaseModel):     prompt: str     max_tokens: int = 50  MODEL_NAME = \"TinyLlama\/TinyLlama-1.1B-Chat-v1.0\"  try:     # \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u044f\u0432\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c device_map     tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)     model = AutoModelForCausalLM.from_pretrained(         MODEL_NAME,         torch_dtype=torch.float32,         device_map=\"auto\",         low_cpu_mem_usage=True     )          # \u0421\u043e\u0437\u0434\u0430\u0435\u043c pipeline \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f device     generator = pipeline(         \"text-generation\",         model=model,         tokenizer=tokenizer     ) except Exception as e:     print(f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438: {str(e)}\")     generator = None  @app.post(\"\/generate\") async def generate_text(request: RequestData):     if not generator:         raise HTTPException(status_code=503, detail=\"\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430\")          try:         output = generator(             request.prompt,             max_new_tokens=min(request.max_tokens, 100),             do_sample=False,             num_beams=1,             temperature=0.7,         )         return {\"response\": output[0][\"generated_text\"]}     except Exception as e:         raise HTTPException(status_code=500, detail=str(e))  @app.get(\"\/health\") async def health_check():     return {\"status\": \"ok\" if generator else \"unavailable\"} <\/code><\/pre>\n<p>\u0420\u0438\u0441.4 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f,  \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/generate \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 json. \u041e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044f \u0445\u043e\u0447\u0443 \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u0449\u0435\u043c\u0443 \u0431\u043b\u043e\u043a\u0443 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\">        output = generator(             request.prompt,             max_new_tokens=min(request.max_tokens, 100),             do_sample=False,             num_beams=1,             temperature=0.7,         ) <\/code><\/pre>\n<p>\u0420\u0438\u0441.5. \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u043f\u0446\u0438\u0439<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u043c\u0438, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a Hugging Face Transformers. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u043f\u0446\u0438\u0439 \u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u043e\u043c\u0438\u0442\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0448\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<br \/> \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 CI\/CD. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/huggingface.co\/spaces\/%D0%B2%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5_%D0%B8%D0%BC%D1%8F_%D0%B2%D0%B0%D1%88%D0%B5%D0%B3%D0%BE_%D0%B0%D0%BA%D0%BA%D0%B0%D1%83%D0%BD%D1%82%D0%B0\/%D0%B2%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5_%D0%B8%D0%BC%D1%8F_%D0%B2%D0%B0%D1%88%D0%B5%D0%B3%D0%BE_spaces?logs=container\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/spaces\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_spaces?logs=container<\/a><\/p>\n<p>\u0418 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0441\u0431\u043e\u0440\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">curl -X POST \"https:\/\/\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430-\u0432\u0432\u0435\u0434\u0438\u0442\u0435_\u0438\u043c\u044f_\u0432\u0430\u0448\u0435\u0433\u043e_spaces .hf.space\/generate\" \u00a0\u00a0-H \"Content-Type: application\/json\" \u00a0\u00a0-d '{\"prompt\":\"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0433\u043e\u0434\u0430?\"}' <\/code><\/pre>\n<p>\u0420\u0438\u0441. 6 curl \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"json\">{\"response\":\"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Docker?\\n\\nDocker - \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Linux \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Linux\" <\/code><\/pre>\n<p>\u0420\u0438\u0441.7 \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u0435\u043c! \u0412\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u0432\u0430\u0448\u0435\u043c VPS, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 Spaces \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 Hugging Face \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u043e\u0431\u0449\u0438\u0445 CPU\/GPU \u0438 \u0438\u043c\u0435\u044e\u0442 \u0440\u044f\u0434 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u0415\u0441\u043b\u0438 \u043a API \u043d\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 48 \u0447\u0430\u0441\u043e\u0432, Space &#171;\u0443\u0441\u043d\u0451\u0442&#187;. \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c (\u043e\u043a\u043e\u043b\u043e 30 \u0441\u0435\u043a\u0443\u043d\u0434).<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432: \u0417\u0430\u043f\u0440\u043e\u0441\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 1-2 \u043c\u0438\u043d\u0443\u0442, \u0431\u0443\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 GPU: \u041c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 CPU, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442:<\/p>\n<ul>\n<li>\n<p>\u0421\u043f\u044f\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c: \u0415\u0441\u043b\u0438 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 Space \u043d\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 48 \u0447\u0430\u0441\u043e\u0432, \u043e\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 &#171;\u0441\u043f\u044f\u0449\u0438\u0439&#187; \u0440\u0435\u0436\u0438\u043c. \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c 30-60 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p>CPU: 1 \u044f\u0434\u0440\u043e, ~1 GB RAM.<\/p>\n<\/li>\n<li>\n<p>GPU (\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e): \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 Space, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043a\u0440\u0443\u0433\u043b\u043e\u0441\u0443\u0442\u043e\u0447\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435: Hugging Face \u043c\u043e\u0436\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c Space, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d \u0431\u043e\u043b\u0435\u0435 90 \u0434\u043d\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041a\u0430\u043a \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c &#171;\u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u044f&#187;?<\/h4>\n<ol>\n<li>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b: \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>cron<\/code> \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/uptimerobot.com\/\" rel=\"noopener noreferrer nofollow\">UptimeRobot<\/a>).<\/p>\n<\/li>\n<li>\n<p>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0442 Hugging Face \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<h4>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b<\/h4>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e <strong>\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/strong> \u2192 <strong>Hugging Face Spaces + FastAPI<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <strong>24\/7 \u0431\u0435\u0437 &#171;\u0437\u0430\u0441\u044b\u043f\u0430\u043d\u0438\u0439&#187;<\/strong> \u2192 <strong>Google Cloud Run<\/strong> \u0438\u043b\u0438 <strong>Fly.io<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d <strong>GPU \u0438 \u043d\u0438\u0437\u043a\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430<\/strong> \u2192 <strong>Hugging Face Inference Endpoints<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435?<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0443, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e.<br \/> \u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043d\u0430 CPU, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c quantization \u2014 \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442 \u0435\u0451 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0435\u0437 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438.<br \/> \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Hugging Face Inference Endpoints \u0438\u043b\u0438 Google Cloud Run \u2014 \u044d\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u044f\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f, \u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a\u0438 \u0438 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0440\u0435\u043f\u043e\u0441\u0442\u044b. <strong>\u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0430.<\/strong> \u0421 \u0432\u0430\u043c\u0438 \u0431\u044b\u043b \u0414\u0443\u0431\u043e\u0432\u0438\u0446\u043a\u0438\u0439 \u042e\u0440\u0438\u0439, \u0430\u0432\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430 <a href=\"https:\/\/t.me\/notReadySir\" rel=\"noopener noreferrer nofollow\">\u00ab\u0412\u0430\u0448 \u043a\u043e\u0434 \u0435\u0449\u0435 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432, \u0441\u044d\u0440\u00bb<\/a>.<br \/> \u0410 \u043d\u0430\u0448 \u043a\u043e\u0434 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432. \u0414\u043e \u0441\u0432\u044f\u0437\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908554\/\"> https:\/\/habr.com\/ru\/articles\/908554\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-459620","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459620"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459620\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}