diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000000..b162ef805a --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,21 @@ +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: doc/source/conf.py + +build: + os: ubuntu-20.04 + tools: + python: "3.9" + +python: + install: + - method: pip + path: python + extra_requirements: + - doc + +submodules: + include: all + recursive: true diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000000..1a2419285d --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,32 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SPHINXINTL ?= sphinx-intl +SOURCEDIR = source +BUILDDIR = build + +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SOURCEDIR) +I18NSPHINXLANGS = -l zh_CN + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile html_zh_cn gettext + +html_zh_cn: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) -t zh_cn -D language='zh_CN' "$(SOURCEDIR)" $(BUILDDIR)/html_zh_cn +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + $(SPHINXINTL) update -p $(BUILDDIR)/locale $(I18NSPHINXLANGS) + python $(SOURCEDIR)/norm_zh.py + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000000..747ffb7b30 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/doc/source/_static/favicon.svg b/doc/source/_static/favicon.svg new file mode 100644 index 0000000000..7853ca959d --- /dev/null +++ b/doc/source/_static/favicon.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000000..66ecb0d49d --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,78 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'Xinference' +copyright = '2023, Xorbits Inc.' +author = 'xorbitsai' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", + "sphinx.ext.autosummary", + "sphinx.ext.napoleon", + "IPython.sphinxext.ipython_directive", + "IPython.sphinxext.ipython_console_highlighting", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# i18n +locale_dirs = ["locale/"] # path is example but recommended. +gettext_compact = False # optional + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'pydata_sphinx_theme' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +html_theme_options = { + "icon_links": [ + { + "name": "GitHub", + "url": "https://github.com/xorbitsai/inference", + "icon": "fa-brands fa-github", + "type": "fontawesome", + }, + ] +} + +html_favicon = "_static/favicon.svg" \ No newline at end of file diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst new file mode 100644 index 0000000000..032ccb04e1 --- /dev/null +++ b/doc/source/getting_started/index.rst @@ -0,0 +1,6 @@ +.. _getting_started_index: + +=============== +Getting Started +=============== + diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000000..bc4d33087a --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,90 @@ +.. _index: + +Xorbits Inference: Model Serving Made Easy🤖 +"""""""""""""""""""""""""""""""""""""""""""" + +Xorbits Inference(Xinference) is a powerful and versatile library designed to serve language, +speech recognition, and multimodal models. With Xorbits Inference, you can effortlessly deploy +and serve your or state-of-the-art built-in models using just a single command. Whether you are a +researcher, developer, or data scientist, Xorbits Inference empowers you to unleash the full +potential of cutting-edge AI models. + + +Key Features +------------ + +🌟 **Model Serving Made Easy**: Simplify the process of serving large language, speech +recognition, and multimodal models. You can set up and deploy your models +for experimentation and production with a single command. + +⚡️ **State-of-the-Art Models**: Experiment with cutting-edge built-in models using a single +command. Inference provides access to state-of-the-art open-source models! + +🖥 **Heterogeneous Hardware Utilization**: Make the most of your hardware resources with +`ggml `_. Xorbits Inference intelligently utilizes heterogeneous +hardware, including GPUs and CPUs, to accelerate your model inference tasks. + +⚙️ **Flexible API and Interfaces**: Offer multiple interfaces for interacting +with your models, supporting RPC, RESTful API(compatible with OpenAI API), CLI and WebUI +for seamless management and monitoring. + +🌐 **Distributed Deployment**: Excel in distributed deployment scenarios, +allowing the seamless distribution of model inference across multiple devices or machines. + +🔌 **Built-in Integration with Third-Party Libraries**: Xorbits Inference seamlessly integrates +with popular third-party libraries like LangChain and LlamaIndex. (Coming soon) + + +Installation +------------ +Xinference can be installed via pip from PyPI. It is highly recommended to create a new virtual +environment to avoid conflicts:: + + pip install "xinference[all]" + + +``xinference[all]`` installs all the necessary packages for serving models. If you want to achieve acceleration on +different hardware, refer to the installation documentation of the corresponding package. + +* `llama-cpp-python `_ is required to run ``baichuan``, ``wizardlm-v1.0``, ``vicuna-v1.3`` and ``orca``. +* `chatglm-cpp-python `_ is required to run ``chatglm`` and ``chatglm2``. + + +Builtin models +-------------- + +To view the builtin models, run the following command:: + + xinference list --all + + ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| Name | Type | Language | Format | Size (in billions) | Quantization | ++===================+==================+===========+=========+====================+=========================================+ +| baichuan | Foundation Model | en, zh | ggmlv3 | 7 | 'q2_K', 'q3_K_L', ... , 'q6_K', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| chatglm | SFT Model | en, zh | ggmlv3 | 6 | 'q4_0', 'q4_1', 'q5_0', 'q5_1', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| chatglm2 | SFT Model | en, zh | ggmlv3 | 6 | 'q4_0', 'q4_1', 'q5_0', 'q5_1', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| wizardlm-v1.0 | SFT Model | en | ggmlv3 | 7, 13, 33 | 'q2_K', 'q3_K_L', ... , 'q6_K', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| wizardlm-v1.1 | SFT Model | en | ggmlv3 | 13 | 'q2_K', 'q3_K_L', ... , 'q6_K', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| vicuna-v1.3 | SFT Model | en | ggmlv3 | 7, 13 | 'q2_K', 'q3_K_L', ... , 'q6_K', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ +| orca | SFT Model | en | ggmlv3 | 3, 7, 13 | 'q4_0', 'q4_1', 'q5_0', 'q5_1', 'q8_0' | ++-------------------+------------------+-----------+---------+--------------------+-----------------------------------------+ + +License +------- +`Apache 2 `_ + + +.. toctree:: + :maxdepth: 2 + :hidden: + + getting_started/index + user_guide/index + reference/index \ No newline at end of file diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/getting_started.po b/doc/source/locale/zh_CN/LC_MESSAGES/getting_started.po new file mode 100644 index 0000000000..e530ed0dc6 --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/getting_started.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 10:54+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/getting_started/index.rst:5 +msgid "Getting Started" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/getting_started/index.po b/doc/source/locale/zh_CN/LC_MESSAGES/getting_started/index.po new file mode 100644 index 0000000000..08d5e0f408 --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/getting_started/index.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 11:00+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/getting_started/index.rst:5 +msgid "Getting Started" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/index.po b/doc/source/locale/zh_CN/LC_MESSAGES/index.po new file mode 100644 index 0000000000..5b456e90dd --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/index.po @@ -0,0 +1,242 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 10:54+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/index.rst:4 +msgid "Xorbits Inference: Model Serving Made Easy🤖" +msgstr "" + +#: ../../source/index.rst:6 +msgid "" +"Xorbits Inference(Xinference) is a powerful and versatile library " +"designed to serve language, speech recognition, and multimodal models. " +"With Xorbits Inference, you can effortlessly deploy and serve your or " +"state-of-the-art built-in models using just a single command. Whether you" +" are a researcher, developer, or data scientist, Xorbits Inference " +"empowers you to unleash the full potential of cutting-edge AI models." +msgstr "" + +#: ../../source/index.rst:14 +msgid "Key Features" +msgstr "" + +#: ../../source/index.rst:16 +msgid "" +"🌟 **Model Serving Made Easy**: Simplify the process of serving large " +"language, speech recognition, and multimodal models. You can set up and " +"deploy your models for experimentation and production with a single " +"command." +msgstr "" + +#: ../../source/index.rst:20 +msgid "" +"⚡️ **State-of-the-Art Models**: Experiment with cutting-edge built-in " +"models using a single command. Inference provides access to state-of-the-" +"art open-source models!" +msgstr "" + +#: ../../source/index.rst:23 +msgid "" +"🖥 **Heterogeneous Hardware Utilization**: Make the most of your hardware " +"resources with `ggml `_. Xorbits " +"Inference intelligently utilizes heterogeneous hardware, including GPUs " +"and CPUs, to accelerate your model inference tasks." +msgstr "" + +#: ../../source/index.rst:27 +msgid "" +"⚙️ **Flexible API and Interfaces**: Offer multiple interfaces for " +"interacting with your models, supporting RPC, RESTful API(compatible with" +" OpenAI API), CLI and WebUI for seamless management and monitoring." +msgstr "" + +#: ../../source/index.rst:31 +msgid "" +"🌐 **Distributed Deployment**: Excel in distributed deployment scenarios, " +"allowing the seamless distribution of model inference across multiple " +"devices or machines." +msgstr "" + +#: ../../source/index.rst:34 +msgid "" +"🔌 **Built-in Integration with Third-Party Libraries**: Xorbits Inference " +"seamlessly integrates with popular third-party libraries like LangChain " +"and LlamaIndex. (Coming soon)" +msgstr "" + +#: ../../source/index.rst:39 +msgid "Installation" +msgstr "" + +#: ../../source/index.rst:40 +msgid "" +"Xinference can be installed via pip from PyPI. It is highly recommended " +"to create a new virtual environment to avoid conflicts::" +msgstr "" + +#: ../../source/index.rst:46 +msgid "" +"``xinference[all]`` installs all the necessary packages for serving " +"models. If you want to achieve acceleration on different hardware, refer " +"to the installation documentation of the corresponding package." +msgstr "" + +#: ../../source/index.rst:49 +msgid "" +"`llama-cpp-python `_ is required to run ``baichuan``, " +"``wizardlm-v1.0``, ``vicuna-v1.3`` and ``orca``." +msgstr "" + +#: ../../source/index.rst:50 +msgid "" +"`chatglm-cpp-python `_ is required to run ``chatglm`` and ``chatglm2``." +msgstr "" + +#: ../../source/index.rst:54 +msgid "Builtin models" +msgstr "" + +#: ../../source/index.rst:56 +msgid "To view the builtin models, run the following command::" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Name" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Type" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Language" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Format" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Size (in billions)" +msgstr "" + +#: ../../source/index.rst:62 +msgid "Quantization" +msgstr "" + +#: ../../source/index.rst:64 +msgid "baichuan" +msgstr "" + +#: ../../source/index.rst:64 +msgid "Foundation Model" +msgstr "" + +#: ../../source/index.rst:64 ../../source/index.rst:66 +#: ../../source/index.rst:68 +msgid "en, zh" +msgstr "" + +#: ../../source/index.rst:64 ../../source/index.rst:66 +#: ../../source/index.rst:68 ../../source/index.rst:70 +#: ../../source/index.rst:72 ../../source/index.rst:74 +#: ../../source/index.rst:76 +msgid "ggmlv3" +msgstr "" + +#: ../../source/index.rst:64 +msgid "7" +msgstr "" + +#: ../../source/index.rst:64 ../../source/index.rst:70 +#: ../../source/index.rst:72 ../../source/index.rst:74 +msgid "'q2_K', 'q3_K_L', ... , 'q6_K', 'q8_0'" +msgstr "" + +#: ../../source/index.rst:66 +msgid "chatglm" +msgstr "" + +#: ../../source/index.rst:66 ../../source/index.rst:68 +#: ../../source/index.rst:70 ../../source/index.rst:72 +#: ../../source/index.rst:74 ../../source/index.rst:76 +msgid "SFT Model" +msgstr "" + +#: ../../source/index.rst:66 ../../source/index.rst:68 +msgid "6" +msgstr "" + +#: ../../source/index.rst:66 ../../source/index.rst:68 +#: ../../source/index.rst:76 +msgid "'q4_0', 'q4_1', 'q5_0', 'q5_1', 'q8_0'" +msgstr "" + +#: ../../source/index.rst:68 +msgid "chatglm2" +msgstr "" + +#: ../../source/index.rst:70 +msgid "wizardlm-v1.0" +msgstr "" + +#: ../../source/index.rst:70 ../../source/index.rst:72 +#: ../../source/index.rst:74 ../../source/index.rst:76 +msgid "en" +msgstr "" + +#: ../../source/index.rst:70 +msgid "7, 13, 33" +msgstr "" + +#: ../../source/index.rst:72 +msgid "wizardlm-v1.1" +msgstr "" + +#: ../../source/index.rst:72 +msgid "13" +msgstr "" + +#: ../../source/index.rst:74 +msgid "vicuna-v1.3" +msgstr "" + +#: ../../source/index.rst:74 +msgid "7, 13" +msgstr "" + +#: ../../source/index.rst:76 +msgid "orca" +msgstr "" + +#: ../../source/index.rst:76 +msgid "3, 7, 13" +msgstr "" + +#: ../../source/index.rst:80 +msgid "License" +msgstr "" + +#: ../../source/index.rst:81 +msgid "`Apache 2 `_" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/reference.po b/doc/source/locale/zh_CN/LC_MESSAGES/reference.po new file mode 100644 index 0000000000..92575c493d --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/reference.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 10:54+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/reference/index.rst:5 +msgid "API Reference" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/reference/index.po b/doc/source/locale/zh_CN/LC_MESSAGES/reference/index.po new file mode 100644 index 0000000000..0f6824d3e2 --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/reference/index.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 11:00+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/reference/index.rst:5 +msgid "API Reference" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/index.po b/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/index.po new file mode 100644 index 0000000000..c61c1d99a6 --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/index.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 11:03+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/user_guide/index.rst:5 +msgid "User Guide" +msgstr "" + diff --git a/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/user_guide.po b/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/user_guide.po new file mode 100644 index 0000000000..217e8fe57d --- /dev/null +++ b/doc/source/locale/zh_CN/LC_MESSAGES/user_guide/user_guide.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, Xorbits Inc. +# This file is distributed under the same license as the Xinference package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Xinference \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-18 11:03+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../source/user_guide/user_guide.rst:5 +msgid "User Guide" +msgstr "" + diff --git a/doc/source/norm_zh.py b/doc/source/norm_zh.py new file mode 100644 index 0000000000..0b960bb030 --- /dev/null +++ b/doc/source/norm_zh.py @@ -0,0 +1,139 @@ +# Copyright 2022-2023 XProbe Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is derived from https://github.com/mars-project/mars/blob/master/docs/source/norm_zh.py + +import datetime +import os + +from babel.messages import pofile +from babel.messages.pofile import escape + + +def _zh_len(s): + """ + Calculate text length in Chinese + """ + try: + return len(s.encode("gb2312")) + except ValueError: + return len(s) + + +def _zh_split(s): + """ + Split text length in Chinese + """ + import jieba + + try: + s.encode("ascii") + has_zh = False + except ValueError: + has_zh = True + + if has_zh: + return list(jieba.cut(s)) + else: + return pofile.WORD_SEP.split(s) + + +# code modified from babel.messages.pofile (hash 359ecffca479dfe032d0f7210d5cd8160599c816) +def _normalize(string, prefix="", width=76): + r"""Convert a string into a format that is appropriate for .po files. + >>> print(normalize('''Say: + ... "hello, world!" + ... ''', width=None)) + "" + "Say:\n" + " \"hello, world!\"\n" + >>> print(normalize('''Say: + ... "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " + ... ''', width=32)) + "" + "Say:\n" + " \"Lorem ipsum dolor sit " + "amet, consectetur adipisicing" + " elit, \"\n" + :param string: the string to normalize + :param prefix: a string that should be prepended to every line + :param width: the maximum line width; use `None`, 0, or a negative number + to completely disable line wrapping + """ + + if width and width > 0: + prefixlen = _zh_len(prefix) + lines = [] + for line in string.splitlines(True): + if _zh_len(escape(line)) + prefixlen > width: + chunks = _zh_split(line) + chunks.reverse() + while chunks: + buf = [] + size = 2 + while chunks: + l = _zh_len(escape(chunks[-1])) - 2 + prefixlen # noqa: E741 + if size + l < width: + buf.append(chunks.pop()) + size += l + else: + if not buf: + # handle long chunks by putting them on a + # separate line + buf.append(chunks.pop()) + break + lines.append("".join(buf)) + else: + lines.append(line) + else: + lines = string.splitlines(True) + + if len(lines) <= 1: + return escape(string) + + # Remove empty trailing line + if lines and not lines[-1]: + del lines[-1] + lines[-1] += "\n" + return '""\n' + "\n".join([(prefix + escape(line)) for line in lines]) + + +def main(): + try: + import jieba # noqa: F401 + except ImportError: + return + + pofile.normalize = _normalize + for root, _dirs, files in os.walk("."): + if "zh" not in root: + continue + for f in files: + if not f.endswith(".po"): + continue + path = os.path.join(root, f) + + # only modify recent-changed files + modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path)) + if (datetime.datetime.now() - modify_time).total_seconds() > 120: + continue + + with open(path, "rb") as inpf: + catalog = pofile.read_po(inpf) + with open(path, "wb") as outf: + pofile.write_po(outf, catalog) + + +if __name__ == "__main__": + main() diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst new file mode 100644 index 0000000000..0ca640ae2b --- /dev/null +++ b/doc/source/reference/index.rst @@ -0,0 +1,5 @@ +.. _reference_index: + +============= +API Reference +============= diff --git a/doc/source/user_guide/index.rst b/doc/source/user_guide/index.rst new file mode 100644 index 0000000000..ad6e9a0eb6 --- /dev/null +++ b/doc/source/user_guide/index.rst @@ -0,0 +1,6 @@ +.. _user_guide_index: + +========== +User Guide +========== + diff --git a/setup.cfg b/setup.cfg index 082ee4bded..6ee1273afe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,11 @@ dev = pytest-timeout>=1.2.0 pytest-forked>=1.0 pytest-asyncio>=0.14.0 + ipython>=6.5.0 + sphinx>=3.0.0,<5.0.0 + pydata-sphinx-theme>=0.3.0 + sphinx-intl>=0.9.9 + jieba>=0.42.0 flake8>=3.8.0 black all = @@ -58,6 +63,11 @@ all = torch accelerate sentencepiece +doc = + ipython>=6.5.0 + sphinx>=3.0.0,<5.0.0 + pydata-sphinx-theme>=0.3.0 + sphinx-intl>=0.9.9 [options.entry_points] console_scripts =