Need help with Drupal or Grav admin, site building, design, or content? Contact us! 

Help Defend Democracy! → Join Battalion today.

Back to top with progress scrollbar

Is there an ethical AI stack for Web Development?

By Reuben Walker, 6 November, 2024
Male an female astronaut work on a lunar base analyzing soil and working with laptop.

Overview

Last month I was in the Halifax airport and had to spend some Canadian dollars before heading back to the U.S. So I picked up two magazines' special issues on AI. They were the Harvard Business Review's How to Thrive in a Gen AI World and MIT Technology Review's Greetings from the Future.

As I read various articles on the flight I came up with the idea for this article, and asked myself is it possible to use "AI" ethically in a web stack?

So, I slowly wrote this post as I came across more items and did some research.

Let's start with some general observations.

The Reasons AI Sucks

If you follow me or have read my weekly news summaries, you know I am not a fan of AI. To this point I think it's a bunch of horseshit, especially generative AI. ML has been around a while and is mostly useful. Hopefully, gen AI will be eventually. But it will have a much bigger challenge being ethical.

Currently it:

  • invades privacy,
  • steals intellectual property,
  • has inherent bias,
  • and is an environmental catastrophe.

Notice that all four of those drawbacks are due to human stupidity or c^ntness. Aka shit in, shit out. Just FYI as we go forward.

AI's Poor Results

Plus in general it just doesn't fucking work.

It only:

  • provides slight improvements,
  • average results,
  • and little ROI.

In other words, its currently a big waste of money and electricity. Of course the idiots selling it and the bigger idiots buying it don't realize this.

Misuse is worse than no use

This is true for anything humans have done throughout history. Just look at the shitshow that religion is. Or capitalism. I am sure you have read or seen dozens of examples of the garbage or hilarious results generative AI currently provides.

For now it's only useful for conspiracy theorists, propagandists, and other assholes. But it doesn't have to be that way.

So if you are going to use it, learn it, and get your shit together first.

Corporate vs Regulatory governance

Keeping the evil AI genie in the bottle is a choice between corporate governance which has always been a joke and regulatory governance which can work if done well. But, that's not likely is it? At least in the United States.

Can we use AI ethically?

In my opinion, we can if we try extremely hard and very carefully. I am going to explore some solutions that are aimed at developers in the Symfony Universe. I will also list some ethical use cases for AI. And finally, suggest a partial stack.

The key to AI is to:

  • only use it when necessary (it currently sucks),
  • always double-check with a human,
  • use it as a new partner, not a replacement,
  • incorporate your values into your strategy,
  • use open-source (if possible),
  • go small which works hand in glove with,
  • keep it local.

So, for the last two, focus on your data and clean it first. Again, no shit in, no shit out.

Now, let's look at some solutions in the Symfony adjacent web development space. We won't cover everything in the list above.

Use Open Source AI

According to the Open Source Initiative:

'To be considered open source under the OSAID, an AI model has to provide enough information about its design so that a person could “substantially” recreate it. The model must also disclose any pertinent details about its training data, including the provenance, how the data was processed, and how it can be obtained or licensed.

Many startups and big tech companies, most prominently Meta, have employed the term “open source” to describe their AI model release strategies — but few meet the OSAID’s criteria.

Maffulli has been openly critical of Meta’s decision to call its models “open source.” After discussions with the OSI, Google and Microsoft agreed to drop their use of the term for models that aren’t fully open, but Meta hasn’t, he said.' 1

So, are there any true Open Source AI models?

I am going to say no. But, the closest thing is Mistral with some of its open models. They are free for non-commercial use.

The French startup has a new product that shows how AI should be used.

Its newest releases are the first generative AI models designed to be run on edge devices, like laptops and phones. AKA keeping it local.

Called “Les Ministraux,” they can be used or tuned for a variety of applications, from basic text generation to working in conjunction with more capable models to complete tasks.

They can ingest roughly the length of a 50-page book. Thus, they do meet the keep it small and keep it local criteria.

“Our most innovative customers and partners have increasingly been asking for local, privacy-first inference for critical applications such as on-device translation, internet-less smart assistants, local analytics, and autonomous robotics,” Mistral writes. 2

They have launched a free service for developers to test its models, and a SDK to let customers fine-tune those models.

Mistral even has a generative model for code called Codestral.

Update 11/26/2024

Ai2 is a nonprofit AI research organization founded by the late Microsoft co-founder Paul Allen. They've released OLMo 2. It meets the Open Source Initiative’s definition of open source AI. This means the tools and data used to develop it are publicly available.

Go Small

Amazee is a player in the Drupal space offering AI hosting and services.

They note:

'As AI technology rapidly evolves, governments and public sector organizations are increasingly updating, creating, and rolling out legislative and compliance frameworks dealing specifically with data privacy, data ownership, and regulations regarding both the responsibility and the liability for the collection, usage, storage, and tracking of corporate and personal data.

At amazee.io, we have always emphasized the critical importance of data sovereignty—especially for organizations with stringent data protection requirements—even before we worked to extend our platform and service offering to cover LLMs, Machine Learning, and AI hosting.

It is a very different situation if your data is stored in Switzerland, Germany, or the United States. Consumers and enterprises want to ensure that their data is only used for approved purposes.' 9

In this case they go small by only using customer data and keep data local by hosting it based on your country.

Once your AI use is integrated, be sure to create automatic and continuous data feedback loops. This will improve its accuracy. And continually monitor it yourself.

Keep it Local

Another good way to keep your AI use local is to only use it on your machine (when rolling your own) or via the other coding tools you use. Everyone in the PHP world has heard of PHP Storm and is probably using it.

They even have their own LLM. But, it is a paid feature so I won't cover it here. If you are interested check out Mellum: JetBrains’ New LLM Built for Developers. It's also not open source but hopefully there will be something similar to it one day.

Regarding the AI integrated into their products JetBrains says:

'Code completion has always been a standout feature in JetBrains IDEs, helping developers code faster, smarter, and with fewer mistakes. But what if it could do even more? What if it could predict not just the next element but entire lines of code – or even complete blocks?

JetBrains offers two ways of delivering AI code completion:

  • Local Full Line Code Completion built into JetBrains IDEs: This works directly on your machine, providing real-time suggestions without requiring an internet connection, which ensures that the suggestions are quick and cater specifically to your project context. Local and included with basic subscription.
  • Cloud-based AI code completion provided by JetBrains AI Assistant: This uses cloud resources to offer more precise code completion, leveraging greater computational power than local resources can provide. Not local and not included.

Unlike tools that bombard you with overwhelming multi-line completions, our AI completion is calibrated to offer concise, relevant suggestions right when you need them.

While large models are often better at handling a variety of tasks, a tailored code model will perform better on specialized tasks. By training a relatively small, highly specialized model and enhancing inference mechanisms, we’ve significantly improved code completion accuracy and speed.' 4

This meets the go small criteria.

'We completely reworked how multi-line suggestions are shown, especially in combination with in-IDE popup completions.

You can now accept completion suggestions token by token or line by line.

With offline and online evaluations in place to assess different retrieval-augmented generation (RAG) strategies, we chose the one that works stably and predictably. Suggestions now utilize the context of the entire project to offer relevant, high-quality blocks of code.' 4

Ok, we've looked at a few developer AI tools, so let's look at ways to put it to use.

Ethical AI Use Cases

If you are following all the strategies in my first list, here are some use cases where you can ethically use AI. Your situation will be unique of course.

Translation

Currently, translation is the best and most appropriate use case for AI. And it can be built into many tools.

Accessibility assistance

This includes things like video transcription and generating alt text for images. However, there is room for a lot more work in this use case.

I would say improving accessibility is the second best use of AI.

Explainers

These would be useful for any technology or product. They are a slimmed down accessory to the next use case.

Learning and education

This has the greatest potential but needs the most work and care.

It would be especially useful for personal learning guides.

Documentation

Obviously programmers are interested in this use case.

Relating to code documentation, Mintlify is an AI generated documentation tool geared toward coding.

'It introduces AI-driven writing suggestions, interactive code snippets, and embedded analytics to transform the way documentation is created, maintained, and, most importantly, used.

Some key features include:

  • Automatic Code Snippets: Mintlify can generate code snippets automatically, saving builders time when they need to demonstrate usage examples.
  • Interactive Documentation: One of Mintlify's best features is its support for interactive elements like live code demos, embedded videos, and other multimedia. Readers who want to try out the examples will find the documentation much more engaging and beneficial.
  • Markdown Support: You can write your documentation using Markdown syntax, and Mintlify will handle the rest, turning it into polished and responsive pages.
  • Customizable Themes: With Mintlify, it’s easy to customize the look of your documentation to match your brand. The platform offers several themes, or you can tailor the design to meet your specific requirements.
  • GitHub Integration: Mintlify can be integrated with your GitHub repositories to keep your documentation up to date with your code changes.
  • Scalability for Large Projects: Mintlify’s collaboration and version control features make it easy to scale documentation as projects grow. This keeps docs current and avoids redundancy, even in complex setups.' 8

Adjusting tone of email/social media

I am sure you have heard of Grammarly and email clients are adding their own AI solutions directly to their products. Unfortunately, the shit that is social media won't be far behind. It would be awesome if it blocked misinformation. But if it's commercial it won't. Hence the use open source criteria.

Legal and medical docs

Editing, explanations, and other ways to get your ass sued off if you don't get it right.

Technical assistance and troubleshooting

This could be useful in any field. FAQ, help sections, chatbots, etc. are examples.

Personal and professional support

Things like automated calendars and reminders.

Content ideation and editing, first drafts

These would be useful but unfortunately that horse has left the barn and gen AI is generating entire horseshit articles on bullshit AI generated websites. And unfortunately lots of dipshits are using it.

Research, analysis, and decision recommendations

This is a long way off in my option due to AI's shit accuracy.

Opensource Web Stack (with AI if/as needed)

So, we have looked at some AI solutions and use cases. Now, what would I recommend for a mostly ethical AI Stack for web development?

To start simple and standards-based are what we should go for here.

We should integrate AI via existing tools rather than world-changing "all in one solutions". Things like Amazee, PHPStorm, Grammarly, Drupal, etc.

For general site use we can integrate AI documentation, search/chatbots based on your sites' content if it is extensive enough, and possibly generate boilerplate code(?) into your new projects.

Open Source AI

For now Mistral as seen above is the best option to integrate LLMs directly into your projects. You are rolling your own and Mistral is the inside of your spliff.

Hosting

Amazee seems to be the most solid option at the moment. They have the expertise to help you integrate AI. SensioLabs and Platform SH won't be far behind with SaaS solutions.

Code Repository, Project Management

Host and work with your code on Codeberg (hosted) or Forgejo (local). There is no AI for now but it will be coming one day. And most likely for code security checks. They are also integrating the Fediverse which is cool. They are open source.

Open Project is another open source option for project management. And works well with Nextcloud.

Cloud Collaboration

I recommend Nextcloud. It says:

'Nextcloud AI Assistant is a capable and versatile tool that enhances your work throughout Nextcloud Hub to keep writing, communication, and other productivity tasks simple and low effort.

Unlike other AI-powered content collaboration tools, Nextcloud doesn’t share your data with a third party technology provider to train the core AI model. This means that all data you work with, including documents, emails, chats and more, stays yours (the local criteria).

We build the AI Assistant using a flexible, solution-independent approach which gives you a choice between multiple large language models (LLM) and services. It can be fully hosted within your instance, processing all requests in-house, or powered by an external service. And importantly, you can have a 100% open-source assistant.

You can ask Nextcloud Assistant about your own data with Context Chat. To answer questions about your documents and assets, Nextcloud Assistant gets access to data from different apps. You can manually define the scope and even limit it to a specific folder or file for more precision.

AI translation is available directly from Nextcloud Assistant menu. Translation options are now almost limitless, as we added support for hundreds of languages that apps can detect, read and translate to.' 7

Languages and Platforms

Vanilla HTML, CSS, JavaScript, and PHP

Web components should be used for customization. AI in IDEs should be able to accomplish this without fucking it up.

PHP code generation should get there as well. Eventually. I mean Rector works so why not.

Symfony

Symfony should lend itself well to AI because it's componentized. Twig is a standard. And you can use Symfony UX rather than JavaScript platforms.

SymfonyCon Vienna has two upcoming sessions on AI

SymfonyCon Vienna 2024: Machine Learning Inference in PHP by example: leverage ONNX and Transformers on Symfony

'Whether you're an AI enthusiast or a developer curious about machine learning, this session will equip you with the knowledge to implement ML inference in your Symfony applications.

This talk will show by example how to implement ONNX (Open Neural Network Exchange) and Transformer models to bring advanced AI capabilities to your Symfony projects.'

SymfonyCon Vienna 2024: Code Less, Create More: Unleashing AI Secret Weapons for Lazy(?) Developers!

'Join Thibault Milan as he explores the transformative power of AI in web development. Discover how tools like GitHub Copilot, Tabnine, Perplexity, and Azure OpenAI are revolutionizing his workflow, enabling faster ideation and seamless entry into new tech areas. Thibault will share insights on integrating AI to improve coding practices, overcome technical limitations, and venture into uncharted territory.

This talk will inspire every developer to view AI as a complement to their skills, not a competitor, preparing them for a future where AI tools are indispensable partners in innovation.'

We'll see where it goes with Symfony.

CMSs

So far Drupal is the only Symfony-based CMS with any AI integrations I would trust. And they are just getting started. And of course it will be open source.

During his recent Driesnote at DrupalCon Barcelona, Dries Buyaert made some AI announcements.

He focused on AI integration within Drupal CMS aka Drupal Starshot.

He said:

'The AI-powered tools are designed to simplify everyday tasks, including renaming content types or configuring fields, reducing the need for manual intervention. These features will operate on four guiding principles:

  • Human oversight, ensuring transparency.
  • Clarity in how AI functions, so users can understand and trust the processes.
  • Customizable models, allowing users to adapt AI to their specific needs (meeting the local criteria).
  • Ethical use, ensuring fairness and avoiding bias.

These AI tools, particularly in content migration and site-building, will provide real value by speeding up processes that typically require developer input.'

Going into more detail he said:

  • 'AI for site building will include agents capable of creating content types, configuring fields, building Views (awesome), forms, and more. These agents will transform how people build and manage websites with Drupal.
  • A responsible AI policy will ensure responsible AI development focusing on four key principles: human-in-the-loop, transparency, swappable large language models (hopefully Mistral), and clear guidance.
  • AI-assisted content migration will crawl your source website and handle complex tasks like mapping unstructured HTML to structured Drupal content types in your destination site, making migrations faster and easier. This could be a game-changer for website migrations.' 6

For more details check out:

Drupal artificial intelligence (AI) community initiative

And for existing Drupal AI solutions (some of which I would not consider ethical use cases, for example OpenAI) see:

  • The Drupal AI module - Offers a comprehensive framework for integrating various AI services into Drupal sites, enabling functionalities such as text generation, image creation or AI search. It features an abstraction layer for seamless integration with third-party AI providers and includes numerous submodules. It also recently merged features from previously best modules such as OpenAI and AI Interpolator.
  • AI Interpolator ecosystem -Chain many different AIs together to create impressive results without needing to know how to code.

Coincidently, ImageX came out with a demonstration article on Drupal AI today. Great minds think alike.

Social Media

ActivityPub can integrate alt text via AI. There will be feed and privacy solutions eventually.

Wrapping it up

Thanks for reading this half-formed and half-finished article on the ethical use of AI. It's kind of like ethical AI itself. It's not quite there yet. Still, I hope you learned some things and please let me know if I got something wrong. I am by no means an expert on AI and to this point I'm not a fan of it. Hopefully, I will be proved wrong in the long run. I'm not optimistic. And as a lifelong pessimist I am usually correct.

Anyway, check out some of the AI tools I covered and give them a try. Just remember the key is to:

  • only use it when necessary
  • always double-check with a human
  • use it as a new partner, not a replacement
  • incorporate your values into your strategy
  • use open-source (if possible)
  • go small which works hand in glove with
  • keep it local

Happy coding with a slight assist from AI. ;)

Resources

1 We finally have an ‘official’ definition for open source AI

2 Mistral releases new AI models optimized for laptops and phones

3 AI and LLM Data Privacy and Data Sovereignty: Navigating the Challenges

4 Complete the Un-Completable: The State of AI Completion in JetBrains IDEs

5 Meet the first open-source AI assistant that doesn’t prey on your data

6 Driesnote

7 Meet the first open-source AI assistant that doesn’t prey on your data

8 Getting started with Mintlify: The smart Documentation tool your team needs

9 AI and LLM Data Privacy and Data Sovereignty: Navigating the Challenges

section separator
Article Type
Donate using Liberapay

Symfony Station covers the essential news in the Symfony, PHP, and Fediverse development communities with a focus on protecting democracy. Please use the button above to make a small donation to help cover our out-of-pocket costs. Our labor is provided free of charge to support the communities we write about.

Join our newsletter list

Subscribe to The Payload, our weekly newsletter exploring the Symfony Universe.

  Start exploring!