I am working on a paper in the field of AI. I've developed a new technology that allows many state of the art benchmarks to be improved on. I want to make sure that when I publish the paper, anyone/company that wants to use the technology can do so free of charge with no strings attached. My fear is that someone will patent the work soon after I publish the paper and prevent this from happening. Should I patent the technology myself before publishing? Is there a better solution?
You need not patent your invention. The requirements of a patent are that it is new, useful and non-obvious. To another person your published work is considered prior art. If someone else tried to patent your work the patent office would reject it as anticipated.
Of course this assumes the patent office finds your work. The inventor could fail to disclose it and the patent office could fail to find it in search. In such a case you can typically submit your work to the relavent patent offices to have the patent/patent application invalidated/rejected.
In countries I'm familiar with, there is the concept of prior art, and scientific publications are a common form of it. Basically, if you make this information public it would invalidate any patent filed based on it* after time of publication. If someone were to obtain such a patent, it can then be challenged by any competitor. So you should just make your results available, and as clearly described as possible. An arXiv posting may be a good idea to establish priority.
However, the public nature of arXiv isn't necessarily required. At least in the US "circulation at a relevant scientific conference" has been considered prior art in the past. It's less clear to me if a poster would provide sufficient evidence of prior art. You may want to consult a patent lawyer (your university likely has one) about that.
*It and (mostly) only it, that is. If someone were to make a significant invention on top of your results, that can still be patentable. But at that point it's no longer your invention.
I want to make sure that when I publish the paper, anyone/company that wants to use the technology can do so free of charge with no strings attached.
Why not put the code up on a public repository such as GitHub with the appropriate license? This will immediately void the need to patent it yourself, and significantly reduce the risk of someone successfully patenting it.
Regarding the actual patenting concerns, the other answers are good, but I'd like to add that if you do find out that someone has patented your work (such as was the case in this question), you are not alone, assuming that you work with a university. Your work is (partially) owned by the academic institution you developed it under, and they do not take kindly to their proprietary rights being infringed upon (to put it mildly). If you are legitimately concerned about your work being patented (or already encounter it as a patent somewhere), let your university handle it. They have lawyers that specialize in this, and they will make absolutely sure that the violators will have an unpleasant time.
Should I patent the technology myself before publishing?
If you do, then you'll need to involve your university (assuming that your work is part of a thesis/you are a faculty member). They will be very reluctant to have you make any part of the work publicly available for the same exact reasons I wrote above - they wouldn't want anyone claiming there is prior art, even if it's yours! Thus, patenting the work will do the exact opposite of what you intend to achieve.
File an application yourself. Preferably both US and EU ("WO"). This is the best method. Unless you genuinely think you've got lightning in a bottle, you're better off weedling your company or school (IP dept) into funding and writing it. In all likelihood, you benefit more from the CV bullet and the plaque than from the commercial invention.
Publish it. In a good, well read journal.
Note: Method 1 is preferable. Method 2, or even just your poster, just "gives you an excuse to sue". But likely won't stop someone else from getting awarded a patent. (A lot of people have the wrong ideas about patents...the true test of patent commercial import comes during litigation.) Method 1 is much more pre-emptive.