{"id":13413551,"url":"https://github.com/nlpodyssey/spago","last_synced_at":"2025-04-29T14:19:16.224Z","repository":{"id":37947329,"uuid":"231973037","full_name":"nlpodyssey/spago","owner":"nlpodyssey","description":"Self-contained Machine Learning and Natural Language Processing library in Go","archived":false,"fork":false,"pushed_at":"2025-04-01T10:17:42.000Z","size":20438,"stargazers_count":1793,"open_issues_count":13,"forks_count":89,"subscribers_count":37,"default_branch":"main","last_synced_at":"2025-04-29T14:19:11.378Z","etag":null,"topics":["artificial-intelligence","automatic-differentiation","automatic-translation","bart","bert","bert-as-service","computation-graph","deep-learning","deeplearning","language-model","lstm","machine-learning","named-entities-recognition","natural-language-processing","neural-network","nlp","question-answering","recurrent-networks","transformer-architecture"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nlpodyssey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"nlpodyssey"}},"created_at":"2020-01-05T20:39:29.000Z","updated_at":"2025-04-28T13:25:01.000Z","dependencies_parsed_at":"2024-06-18T12:39:21.882Z","dependency_job_id":"bcf0c1d9-9ec7-4819-bf04-4d86f007a944","html_url":"https://github.com/nlpodyssey/spago","commit_stats":{"total_commits":2097,"total_committers":14,"mean_commits":"149.78571428571428","dds":"0.41726275631855037","last_synced_commit":"43e162f51077fe8313835fdce0c1dd6cf47d870c"},"previous_names":["saientist/spago"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlpodyssey%2Fspago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlpodyssey%2Fspago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlpodyssey%2Fspago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlpodyssey%2Fspago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlpodyssey","download_url":"https://codeload.github.com/nlpodyssey/spago/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251516951,"owners_count":21601911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","automatic-differentiation","automatic-translation","bart","bert","bert-as-service","computation-graph","deep-learning","deeplearning","language-model","lstm","machine-learning","named-entities-recognition","natural-language-processing","neural-network","nlp","question-answering","recurrent-networks","transformer-architecture"],"created_at":"2024-07-30T20:01:42.999Z","updated_at":"2025-04-29T14:19:16.203Z","avatar_url":"https://github.com/nlpodyssey.png","language":"Go","funding_links":["https://opencollective.com/nlpodyssey"],"categories":["Go","Natural Language Processing","自然语言处理","Microsoft Office","General Machine Learning libraries","Relational Databases","Bot Building"],"sub_categories":["Morphological Analyzers","Uncategorized","形态分析","Vector Database","[Tools](#tools-1)"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://github.com/nlpodyssey/spago/blob/main/assets/spago_logo.png\" width=\"400\"/\u003e\n    \u003cbr\u003e\n\u003cp\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/nlpodyssey/spago/actions/workflows/go.yml?query=branch%3Amain\"\u003e\n        \u003cimg alt=\"Build\" src=\"https://github.com/nlpodyssey/spago/actions/workflows/go.yml/badge.svg?branch=main\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/nlpodyssey/spago\"\u003e\n        \u003cimg alt=\"Coverage\" src=\"https://codecov.io/gh/nlpodyssey/spago/branch/main/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/nlpodyssey/spago\"\u003e\n        \u003cimg alt=\"Go Report Card\" src=\"https://goreportcard.com/badge/github.com/nlpodyssey/spago\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codeclimate.com/github/nlpodyssey/spago/maintainability\"\u003e\n        \u003cimg alt=\"Maintainability\" src=\"https://api.codeclimate.com/v1/badges/be7350d3eb1a6a8aa503/maintainability\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/nlpodyssey/spago/\"\u003e\n        \u003cimg alt=\"Documentation\" src=\"https://pkg.go.dev/badge/github.com/nlpodyssey/spago/.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/BSD-2-Clause\"\u003e\n        \u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-BSD%202--Clause-orange.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://makeapullrequest.com\"\u003e\n        \u003cimg alt=\"PRs Welcome\" src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/avelino/awesome-go\"\u003e\n        \u003cimg alt=\"Awesome Go\" src=\"https://awesome.re/mentioned-badge.svg\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003ci\u003eIf you like the project, please ★ star this repository to show your support! 🤩\u003c/i\u003e\n    \u003cbr\u003e\n\u003cbr\u003e\n\u003cp\u003e\n\n\u003e 15 Jan 2024 - As I reflect on the journey of Spago, I am filled with gratitude for the enriching experience it has provided me. Mastering Go and revisiting the fundamentals of Deep Learning through Spago has been immensely rewarding. The unique features of Spago, especially its asynchronous computation graph and focusing on clean coding, have made it an extraordinary project to work on. Our goal was to create a minimalist ML framework in Go, eliminating the dependency on Python in production by enabling the creation of standalone executables. This approach of Spago successfully powered several of my projects in challenging production environments.\n\u003e \n\u003e However, the endeavor to elevate Spago to a level where it can compete effectively in the evolving 'AI space', which now extensively involves computation on GPUs, requires substantial commitment. At the same time, the vision that Spago aspired to achieve is now being impressively realized by the [Candle](https://github.com/huggingface/candle) project in Rust. With my limited capacity to dedicate the necessary attention to Spago, and in the absence of a supporting maintenance team, I have made the pragmatic decision to pause the project for now.\n\u003e\n\u003e I am deeply grateful for the journey Spago has taken me on and for the community that has supported it. As we continue to explore the ever-evolving field of machine learning, I look forward to the exciting developments that lie ahead.\n\u003e \n\u003e Warm regards,\n\u003e\n\u003e Matteo Grella\n\n---\n\nSpago is a **Machine Learning** library written in pure Go designed to support relevant neural architectures in **Natural\nLanguage Processing**.\n\nSpago is self-contained, in that it uses its own lightweight computational graph both for training and\ninference, easy to understand from start to finish. \n\nIt provides:\n- Automatic differentiation via dynamic define-by-run execution\n- Feed-forward layers (Linear, Highway, Convolution...)\n- Recurrent layers (LSTM, GRU, BiLSTM...)\n- Attention layers (Self-Attention, Multi-Head Attention...)\n- Gradient descent optimizers (Adam, RAdam, RMS-Prop, AdaGrad, SGD)\n- Gob compatible neural models for serialization\n\nIf you're interested in NLP-related functionalities, be sure to explore the [Cybertron](https://github.com/nlpodyssey/cybertron) package!\n\n## Usage\n\nRequirements:\n\n* [Go 1.21](https://golang.org/dl/)\n\nClone this repo or get the library:\n\n```console\ngo get -u github.com/nlpodyssey/spago\n```\n\n### Getting Started\n\nA good place to start is by looking at the implementation of built-in neural models, such as the LSTM.\n\n### Example 1\nHere is an example of how to calculate the sum of two variables:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/nlpodyssey/spago/ag\"\n\t\"github.com/nlpodyssey/spago/mat\"\n)\n\nfunc main() {\n\t// define the type of the elements in the tensors\n\ttype T = float32\n\n\t// create a new node of type variable with a scalar\n\ta := mat.Scalar(T(2.0), mat.WithGrad(true)) // create another node of type variable with a scalar\n\tb := mat.Scalar(T(5.0), mat.WithGrad(true)) // create an addition operator (the calculation is actually performed here)\n\tc := ag.Add(a, b)\n\n\t// print the result\n\tfmt.Printf(\"c = %v (float%d)\\n\", c.Value(), c.Value().Item().BitSize())\n\n\tc.AccGrad(mat.Scalar(T(0.5)))\n\n\tif err := ag.Backward(c); err != nil {\n\t\tlog.Fatalf(\"error during Backward(): %v\", err)\n\t}\n\n\tfmt.Printf(\"ga = %v\\n\", a.Grad())\n\tfmt.Printf(\"gb = %v\\n\", b.Grad())\n}\n```\n\nOutput:\n\n```console\nc = [7] (float32)\nga = [0.5]\ngb = [0.5]\n```\n\n### Example 2\n\nHere is a simple implementation of the perceptron formula:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\n\t. \"github.com/nlpodyssey/spago/ag\"\n\t\"github.com/nlpodyssey/spago/mat\"\n)\n\nfunc main() {\n\tx := mat.Scalar(-0.8)\n\tw := mat.Scalar(0.4)\n\tb := mat.Scalar(-0.2)\n\n\ty := Sigmoid(Add(Mul(w, x), b))\n\n\tfmt.Printf(\"y = %0.3f\\n\", y.Value().Item())\n}\n```\n\n## Contributing\n\nIf you think something is missing or could be improved, please open issues and pull requests.\n\nTo start contributing, check the [Contributing Guidelines](https://github.com/nlpodyssey/spago/blob/main/CONTRIBUTING.md).\n\n## Contact\n\nWe highly encourage you to create an issue as it will contribute to the growth of the community. However, if you prefer to communicate with us privately, please feel free to email [Matteo Grella](mailto:matteogrella@gmail.com) with any questions or comments you may have.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlpodyssey%2Fspago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlpodyssey%2Fspago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlpodyssey%2Fspago/lists"}